www.webdeveloper.com
Results 1 to 3 of 3

Thread: [RESOLVED] Converting timestamps

  1. #1
    Join Date
    Jan 2008
    Location
    ON CA
    Posts
    58

    resolved [RESOLVED] Converting timestamps

    Hi,
    In PHP4, I need to convert a Unix timestamp in the format '2008-10-21 00:00:00' to an integer timestamp that will work with date(). How do I do it?

    Thank you.

    EDIT: Right now I'm doing this:
    PHP Code:
    echo "<strong>".date('d M/y',$sitenews['date'])."</strong><br>\n" 
    but the date displayed is 31 Dec/69 instead of the correct date.
    Last edited by hex1a4; 10-21-2008 at 07:10 PM.

  2. #2
    Join Date
    Jun 2003
    Location
    here
    Posts
    4,551
    hmn, you need to rearange the early part of your number:
    PHP Code:
    $dateAr1 explode(' '$sitenews['date']);
    $dateAr2 explode('-'$dateAr1[0]);
    $dateAr3 explode(':'$dateAr1[1]);

    $timeStamp mktime($dateAr3[0],$dateAr3[1], $dateAr3[2], $dateAr2[1], $dateAr2[2], $dateAr2[0]);

    echo 
    "<strong>".date('d M/y',$timeStamp)."</strong><br>\n" 
    If you are using PHP please use the [PHP] and [/PHP] forum tags for highlighting...
    The same applies to HTML and the forums [HTML][/HTML] tags.

  3. #3
    Join Date
    Jan 2008
    Location
    ON CA
    Posts
    58
    This did the trick. Thank you.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles