echo time(); gives me timestamp 1293645728开发者_Go百科 which is a timestamp of Wed Dec 31 19:00:00 EST 1969 instead of current timestamp.
In my php.ini date.timezone="US/Eastern".I am using windows and thextension=php_timezonedb.dll , I have restarted apache several times .
Any help is appreciated.
This is my date function .date("D M j G:i:s T Y", strtotime(time()));
strtotime is giving you incorrect results because a UNIX timestamp is an int not a string. That's OK, though, because date takes an int, not a string:
date("D M j G:i:s T Y", time());
Edit:
In fact, this is redundant as date
defaults its second argument to the value of time()
:
date("D M j G:i:s T Y");
instead of
date("D M j G:i:s T Y", strtotime(time()));
just write:
date("D M j G:i:s T Y");
A timestamp of 1293645728 is in fact Wed, 29 Dec 2010 18:02:08. As such, I suspect there's something wrong elsewhere. (i.e.: It's not PHP.)
For example:
<?php
echo date('r', 1293645728);
?>
0 is 1970 (beginning of unix epoch), 1293645728 is far from 0. Your timestamp returns 12 / 29 / 10 @ 12:02:08pm
echo date("d.m.Y H:i:s", time());
What does it return?
It looks to me like you converted the timestamp wrong, as Wolfram alpha gave me the conversion that you seem to be looking for: 6:02:08 pm UTC | Wednesday, December 29, 2010
Did you do the conversion wrong?
精彩评论