Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Displaying store time on magento frontend
 
muk_t
Sr. Member
 
Total Posts:  226
Joined:  2012-07-24
 

Hi,

I want to display the store time on magento frontend like a digital clock.
Can any one please help me how can i do his?

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
MattStephens
Sr. Member
 
Avatar
Total Posts:  152
Joined:  2011-07-12
United Kingdom
 

Hello muk_t

Depending on where you want to display the time, you could either modify an existing layout (for example the header or footer) and place the following code in there:

<?php echo date("h:i" ,time());  ?>

Alternatively (and a better way of doing things), you could create a new “block” and then this allows you to insert wherever you’d like. Here is a great tutorial on creating new blocks if you’ve not created on before.

Cheers
Matt

 
Magento Community Magento Community
Magento Community
Magento Community
 
muk_t
Sr. Member
 
Total Posts:  226
Joined:  2012-07-24
 

@MattStephens

thanks for you help ,when I tried this this shows a static time,I want time to be displayed like a clock manner .
If you know about this please help.

 
Magento Community Magento Community
Magento Community
Magento Community
 
aygromania
Jr. Member
 
Avatar
Total Posts:  7
Joined:  2012-08-09
 
muk_t - 29 October 2012 03:08 AM

@MattStephens

thanks for you help ,when I tried this this shows a static time,I want time to be displayed like a clock manner .
If you know about this please help.

The reason it shows a static time is because the code is executed only once.
In order to make a dynamic clock you can initialize a javascript date-time variable using the date function from php, and using javascript code, you can display the current time.

Here is a tutorial for this http://www.javascriptkit.com/script/script2/servertime.shtml

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top