Jake
Jake

Reputation: 26137

Get GMT timestamp using Zend_Date

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->getIso();

Upvotes: 1

Views: 7566

Answers (1)

Ish
Ish

Reputation: 29606

/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());

Upvotes: 2

Related Questions