SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Guru adammc's Avatar
    Join Date
    Aug 2004
    Location
    Cairns, Australia
    Posts
    762
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP date - format

    Hi guys,

    I am storing the date (2007-08-23 11:11:12) in a datetime field in MYSQL DB.

    I wish to display it as: '23rd Aug 2007' but cant seem to achive this??
    Im fetching the last login time from the Db when I log the user in and storing it in a session.

    PHP Code:
    $last_login date("Y-m-d H:i:s"$_SESSION['lastlogin']); 
    Can anyone possibly help?

  2. #2
    SitePoint Guru adammc's Avatar
    Join Date
    Aug 2004
    Location
    Cairns, Australia
    Posts
    762
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think i got it sorted !!!!

    $last_login = date('d M Y', strtotime($_SESSION['lastlogin']));

    Please correct me if wrong

  3. #3
    play of mind Ernie1's Avatar
    Join Date
    Sep 2005
    Posts
    1,252
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $last_login date("dS M Y"strtotime($_SESSION['lastlogin'])); 
    my mobile portal
    ghiris.ro

  4. #4
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,788
    Mentioned
    151 Post(s)
    Tagged
    3 Thread(s)
    An alternative would have been to let mysql do the date conversion when it is querying for the user data.

    Code:
    select date_format(date_field,  '%D %M %Y') as last_login
    Not really much difference, just another way
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....


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
  •