0

I need to get the current local time of the customer's location.
One method is to do it by: Mage::getModel('core/date').

But I need to extract the day number and current time from it, which can be done very nicely by Zend_Date::WEEKDAY_DIGIT and
Zend_Date::TIME_SHORT,
but the "current time placeholder" for Zend is: Zend_Date::now(); which takes the current time of the server and not the customer.

Is there a way I can use these Zend functions with Mage::getModel('core/date') timestamp, and if not, how do I achieve the same functionality?

3

Figured out a way myself!

$time = new Zend_Date(Mage::getModel('core/date')->timestamp()); 
$day_number = $time->get(Zend_Date::WEEKDAY_DIGIT);
$current_time = $time->get(Zend_Date::TIME_SHORT);

Can also be done without Zend:

$time = Mage::getModel('core/date'); 
$day_number = $time->date('N'); 
$current_time = $time->date('H:i');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.