PHP Timezone problem
I am in Albuquerque, NM. I am trying to update some stamps every time I put an entry into a database.
Here is what I use.
date_default_timezone_set("US/Mounta开发者_如何学JAVAin");
$stamp =mktime();
//$stamp = gmmktime();
$time = date("H:i:s",$stamp);$date = date("Y-m-d",$stamp);
My local time is 12:15 PM but what I get is 18:15PM instead.
If you can see what's going wrong please let me know.
"My local time is 12:15 PM but what I get is 18:15PM instead."
6 hours ...that's the offset between UTC and American/Mountain, 18:00 in your local timezone is 12:00 UTC.
What does
$rc = date_default_timezone_set("US/Mountain");
$stamp =mktime();
echo 'version: ', phpversion(), "\n";
echo 'rc=', var_dump($rc);
echo 'stamp: ', $stamp, "\n";
echo 'time(): ', time(), "\n";
echo 'date: ', date(DateTime::ISO8601, $stamp), "\n";
echo 'gmdate: ', gmdate(DateTime::ISO8601, $stamp), "\n";
print?
Try date_default_timezone_set("America/Denver");
精彩评论