1

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();
ajreal
  • 46,720
  • 11
  • 89
  • 119
Jake
  • 25,479
  • 31
  • 107
  • 168
  • See: [http://stackoverflow.com/questions/1550432/how-to-use-zend-date-to-print-a-time-in-a-specific-timezone][1] for using Zend_Date::setTimezone() [1]: http://stackoverflow.com/questions/1550432/how-to-use-zend-date-to-print-a-time-in-a-specific-timezone – Jari Turkia Dec 08 '12 at 17:16

1 Answers1

2

/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());
CDuv
  • 2,098
  • 3
  • 22
  • 28
Ish
  • 28,486
  • 11
  • 60
  • 77