"Wednesday 31st December 1969" - Why am i getting this date? Date Function

Discussion in 'PHP' started by jeeplaw, Feb 13, 2008.

  1. #1
    Anyone run across this? Is is indicative of the UNIX time on the server or something else? Here's the code I'm using..

    
     ob_start();
     $internal->parseMailTemplate( $custom->displayPage( 61 ), $authorInfo );
     $timestamp = ob_get_contents();
     ob_end_clean();
    $thedate2 = date('l dS F Y', (int) $timestamp);
    
     echo "Date joined: "; print $thedate2;
    
    
    Code (markup):
    When someone adds an account to the website, the join on date is registered into the db. Any ideas?
     
    jeeplaw, Feb 13, 2008 IP
  2. jayshah

    jayshah Peon

    Messages:
    1,126
    Likes Received:
    68
    Best Answers:
    1
    Trophy Points:
    0
    #2
    Check what the value of $timestamp actually is.

    31st December 1969 is actually one second (or more) before the UNIX Timestamp begins (1st January 1970).

    Jay
     
    jayshah, Feb 13, 2008 IP
  3. Cobnut

    Cobnut Peon

    Messages:
    184
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #3
    What's the '(int)' bit in the date function?

    Jon
     
    Cobnut, Feb 13, 2008 IP
  4. jayshah

    jayshah Peon

    Messages:
    1,126
    Likes Received:
    68
    Best Answers:
    1
    Trophy Points:
    0
    #4
    (int) causes PHP to return the integer part of $timestamp. It is not part of the date function.
     
    jayshah, Feb 13, 2008 IP
  5. walkere

    walkere Active Member

    Messages:
    112
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    58
    #5
    I just did some testing out of curiosity, and any timestamp between 0 and (60 * 60 * 5) (5 hours) comes up as Dec 31 1969 for me. Is that a time zone issue?

    However, the point being, a $timestamp of 0 or null would give you the date Dec 31 1969. So the function getting $timestamp may be returning 0 or null as an error.

    - Walkere
     
    walkere, Feb 13, 2008 IP