Results 1 to 8 of 8

Thread: time stamp

  1. #1
    Join Date
    Aug 2005
    Posts
    174
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default time stamp

    hello,
    i have a mySQL database with a timestamp to record when a user submits a comment.
    PHP Code:
    $Date $row[date]; 
    How can I change this to "Thursday, 21st January 2008"

    when used in this case:

    PHP Code:
    echo ("$Date"); 

    Thanks for your help!

  2. #2
    Join Date
    Oct 2008
    Posts
    42
    Thanks
    0
    Thanked 9 Times in 9 Posts

    Default

    PHP Code:
    $date_out date('l jS F Y'$Date); 
    more info

  3. #3
    Join Date
    Aug 2005
    Posts
    174
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    Thanks, I thought that too, but it doesnt work! it keeps using the default date of:

    Code:
    Thursday 1st January 1970
    I have no idea why!

    Apache version 2.2.9 (Unix)
    PHP version 5.2.6
    MySQL version 4.1.22-standard

  4. #4
    Join Date
    Oct 2008
    Posts
    42
    Thanks
    0
    Thanked 9 Times in 9 Posts

    Default

    That's because $Date contains the value 0.

  5. #5
    Join Date
    Aug 2005
    Posts
    174
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    nope, because if I
    PHP Code:
    echo ("$Date"); 
    i get the value 2008-11-28 09:43:27

  6. #6
    Join Date
    Aug 2005
    Posts
    174
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    here's the full code:
    PHP Code:
    $Date $row[date];

    $date_out date('l jS F Y'$Date);

    echo (
    "$date_out");
    echo (
    "$Date"); 
    Of which, the output is:
    Code:
    Thursday 1st January 1970
    2008-11-28 09:43:27

  7. #7
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Use strtotime() to convert the date being returned from the sql query to a unix timestamp and then pass that value to the date function as mentioned before.

    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  8. #8
    Join Date
    Oct 2008
    Posts
    42
    Thanks
    0
    Thanked 9 Times in 9 Posts

    Default

    Well
    Code:
    Thursday 1st January 1970
    2008-11-28 09:43:27
    is NOT a timestamp.

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
  •