By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,304 Members | 1,242 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,304 IT Pros & Developers. It's quick & easy.

date formatting question

P: n/a
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
Jul 16 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi,

Bernhard Hörlberger wrote:
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?


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

Jul 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.