date formatting question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bernhard Hörlberger

    date formatting question

    I use the following to print out a date:

    <?php print date("Y-m-d H:i:s", $aUser["Created Date"]) ?>
    // $aUser["Created Date"] contains "2003-08-18 14:21:47"

    but what is printed out is the following:

    1970-01-01 01:33:23

    Any idea why?

    thanks a lot in advance,
    Bernhard


  • Luke Ross

    #2
    Re: date formatting question

    Hi,

    Bernhard Hörlberger wrote:[color=blue]
    > I use the following to print out a date:
    >
    > <?php print date("Y-m-d H:i:s", $aUser["Created Date"]) ?>
    > // $aUser["Created Date"] contains "2003-08-18 14:21:47"
    >
    > but what is printed out is the following:
    >
    > 1970-01-01 01:33:23
    >
    > Any idea why?[/color]

    The second parameter to date() is a numerical value, the number of
    seconds since the epoch (1970-1-1 normally). Your string is cast to the
    number 2003, and 2003 seconds since the epoch is the output you get.

    See http://uk2.php.net/manual/en/function.strtotime.php for a function
    that will help you :-)

    Regards,

    Luke

    Comment

    Working...