SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: date formatting

  1. #1
    SitePoint Evangelist
    Join Date
    Dec 2006
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    date formatting

    Hi Guys,

    when a user logs into my site mysql records the date as:

    PHP Code:
    2007-04-29 22:13:42 
    i was after making it say:

    PHP Code:
    April 29200722:13 pm 
    how would i go about doing this?

    Thanks guys

    Graham

  2. #2
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,423
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    date("F j, Y, H:i a", strtotime('2007-04-29 22:13:42 '))

  3. #3
    SitePoint Evangelist
    Join Date
    Dec 2006
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks mate

    Graham

  4. #4
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,813
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Or better yet use the appropriate mySQL command to retrieve it the way that you want rather than using PHP to convert it after retrieval.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  5. #5
    SitePoint Evangelist
    Join Date
    Dec 2006
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Felgall,

    could you tell me the command i would need to do that? that sounds good aswell (if slightly better)

    this is what i did to make it convert:

    PHP Code:
             $date_format $row["login"]; 
             
    $display_date date("F j-Y-H:i a"strtotime($date_format));
    echo 
    $display_date
    thanks mate

    Graham

  6. #6
    SitePoint Evangelist barbara1712's Avatar
    Join Date
    Apr 2007
    Location
    India
    Posts
    509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can also use the select command of mysql to retrieve the date like:

    select date_format(logged_on,'&#37;M %d, %Y, %H:%i %p') as date1 from table_name
    Last edited by barbara1712; Apr 30, 2007 at 06:47.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •