开发者

Get GMT timestamp using Zend_Date

开发者 https://www.devze.com 2023-01-28 13:15 出处:网络
I use the following code to get current time stamp. How do I get GMT time instead of local time? $date = Zend_Date::now();

I use the following code to get current time stamp. How do I get GMT time instead of local time?

$date = Zend_Date::now();
$timeStamp = $date->getIs开发者_StackOverflowo();


/Zend/Date.php said

 * Always set the default timezone: http://php.net/date_default_timezone_set
 * For example, in your bootstrap: date_default_timezone_set('America/Los_Angeles');

If your timezone is different and you still want to get GMT without changing default try this

$date = Zend_Date::now();
$timeStamp = gmdate("Y-m-d H:i:s", $date->getTimestamp());
0

精彩评论

暂无评论...
验证码 换一张
取 消