i found many articals on this but none of give proper soluation
my current system timezone is = 'asia/Kolkata'
my current magento timezone is 'asia/shanghai'
this give me de correct UTC time here system time is '2013-06-26 15:34:00'
$timezone = date_default_timezone_get();
date_default_timezone_set($timezone);
$now = Mage::getModel('core/date')->timestamp(time());
$current_date= date('Y-m-d H:i:s');
so here $current_date = '2013-06-26 18:04:30'
but i have another mytimestamp..... ex :- $time = '2013-06-26 15:34:00';
$scheduletime = '2013-06-26 15:19:00';
$dateTimestamp = Mage::getModel('core/date')->timestamp(strtotime($scheduletime));
$schedule_time = date('Y-m-d H:i:s',strtotime($scheduletime));
so here $schedule_time = '2013-06-26 23:34:00'
so actually what i want is to get difference between this two time and it should be : 0
Try
Mage::getSingleton('core/date')->gmtDate();
Note: UTC and GMT are equal.
Use strtotime to generate a timestamp from the given string (interpreted as local time) and use gmdate to get it as a formatted UTC date back.
For example
As requested, here’s a simple example:
echo gmdate('d.m.Y H:i', strtotime('2012-06-28 23:55'));
or you can also use local setting with store like below
Mage::app()->getLocale()->storeDate(
$this->getStore(),
Varien_Date::toTimestamp($this->getCreatedAt()),
true
);
where $this->getCreatedAt() your Database date.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With