Jump to content

Display Current Date and Time


Recommended Posts

Thanks for your reply :-)

The module looks great, but I was looking for something a bit simpler since my shop is rather crowded already.

Displaying something like:

18:00 hours
Monday January 1

..is al I really need.

Anyone know how to do this?


Cheers,


Sanook

Link to comment
Share on other sites

Thanks for your reply.

But this script will display the time of the user's computer if I'm not mistaken.

I am looking for a script that displays the current date and time set on my server.
Perhaps I should have made this more clear in my question, sorry.

My server is located in Thailand, and my customers are from the US and UK, amongst others.
I would like to show them the Thai date and time, for customer service reasons etc.

Anyone?

Link to comment
Share on other sites

Try adding this code to one of your modules. For example, on line 101 of modules/blockinfos/blockinfos.php, before the return, you could add:

$today = getdate();
echo $today['hours'] . ':' . $today['minutes'] . ' hours
' . $today['weekday'] . ' ' . $today['month'] . ' ' . $today['mday'];



There is probably a better place you could place it. You could also store the date in a string and pass it into a tpl file.

Link to comment
Share on other sites

Thanks Rocky, it works nicely :-)


You could also store the date in a string and pass it into a tpl file.


Can you tell me how do this, I don't know much about php.
I understand what you mean, but I just don't know where to put the code.

My aim is to display this time in the right column/sidebar of my shop.

I was able to put a little flash clock using the footer.tpl file,
but I don't know how to make php or smarty code work there.

Best regards,


Sanook
Link to comment
Share on other sites

To be more specific, if, for example, you have the information block in your right sidebar and want to add the current time above it, you could edit modules/blockinfos/blockinfo.php and add the following code at line 102, before the return:

$today = getdate();
$smarty->assign('current_time', $today['hours'] . ':' . $today['minutes'] . ' hours
' . $today['weekday'] . ' ' . $today['month'] . ' ' . $today['mday']);



You could then edit modules/blockinfos/blockinfo.tpl and add something like the following to the top of the file:

{$current_time}

Link to comment
Share on other sites

To be more specific, if, for example, you have the information block in your right sidebar and want to add the current time above it, you could edit modules/blockinfos/blockinfo.php and add the following code at line 102, before the return:

$today = getdate();
$smarty->assign('current_time', $today['hours'] . ':' . $today['minutes'] . ' hours
' . $today['weekday'] . ' ' . $today['month'] . ' ' . $today['mday']);



You could then edit modules/blockinfos/blockinfo.tpl and add something like the following to the top of the file:

{$current_time}




You're the greatest! Everything is working :-)

Thanks so much for your help.

Best regards,

Sanook
Link to comment
Share on other sites

Am trying to put a flash clock.
Everything works until I put the last two params: &UTCTime;and &timeoffset;

<object type="application/x-shockwave-flash" data="media/devAnalogClock.swf" width="200" height="200">




</object>




It should be getting the time from my server, but it doesn't work.
The clock stops working.

Btw: I have put the code in footer.tpl to be displayed in the right column.

Anyone know how to make this work?

Link to comment
Share on other sites

I got a javascript version too, but don't know where to put either code...

[removed]<!--
   var flashvars = {
       clockSkin: "media/skins/skin004.png",
       arrowSkin: "7",
       showSeconds: "no",
       arrowScale: "70",
       UTCTime: "<?php echo gmdate('H:i:s'); ?>",
       timeOffset: "3600"
   };
   swfobject.embedSWF(
       "devAnalogClock.swf",
       "devAnalogClock",
       "220",
       "220",
       "8",
       "expressInstall.swf",
       flashvars,
       {scale: "noscale", wmode: "transparent"}
   );
// -->[removed]




Updated: [removed] means jscript :-)

Link to comment
Share on other sites

  • 1 month later...

Rocky - your solution works OK, but it doesn't adjust for daylight savings time and alo it shows (for example) 12:4 instead of 12:04.

How can I get it to account for daylight saving and sort out the missing 0?? Otherwise, this is a nice easy to use bit of code.

The javascript version on dynamic drive looks good as it uses the time of the users's computer, so this gets around daylight savings and all that. However, I don't know how to get it to work - it breaks the page if I just pop the coded in as it instructs.

Link to comment
Share on other sites

Hi babyewok,

You may be right. I didn't fully test the code. I think changing

$today['minutes']

to

($today['minutes'] < 10 ? '0' : '') . $today['minutes']

will fix the missing 0, but I just assumed that PHP would handle daylight savings. If you give me a link to the javascript, I can try to get it to work in Prestashop.

Rocky

Link to comment
Share on other sites

Hi, I went to a php forum and also to the hosting provider and discovered that the daylight savings issue was down to a setting in config.inc.php. It read on line 16:

date_default_timezone_set('Europe/Paris');



so I changed it to

date_default_timezone_set('Europe/London');



I hadn't realised that Prestashop was controlling the timezone.

With regards to the zero, a guy at php builder gave me this to use instead and it works fine:

$today = getdate();
$smarty->assign('current_time', date('l F j Y H:i')); 

Link to comment
Share on other sites

  • 1 month later...

Hi guys,

I’ve change my system date to ‘Asia/Kuala_lumpur’ and work great. But format are different at BO and user email. Below is the example:

2009-06-20 23:03:26 << date display at BO (Orders) – 24hours format

Order: #000037 placed on 2009-06-20 11:03:27 << date display at user email (Order Confirmation) – 12 hours format

Where to change the format for user email to 24hours format?

Link to comment
Share on other sites

  • 4 months later...
  • 1 year later...
To be more specific, if, for example, you have the information block in your right sidebar and want to add the current time above it, you could edit modules/blockinfos/blockinfo.php and add the following code at line 102, before the return:

$today = getdate();
$smarty->assign('current_time', $today['hours'] . ':' . $today['minutes'] . ' hours
' . $today['weekday'] . ' ' . $today['month'] . ' ' . $today['mday']);



You could then edit modules/blockinfos/blockinfo.tpl and add something like the following to the top of the file:

{$current_time}




I wanted to put this code in the verses. 1.4 to display the date in the title of the products on display.
I wish I had written this: the new products in April and make changes alone, but I can not get it working in my php file to parse error, I do not know php so I'm not able to correct any error
Link to comment
Share on other sites

  • 2 years later...
  • 4 years later...

Hello can someone help in this problem...

I've looked this solution and for me it should be work...
I only want to know where i can put the php code that are show in this forum, my result it would be this:
I have unavailable products and when there is a date for product to be available i would like to put the date in the flag (done), but in some products the available date is pass that the current time and i wanna only show the date if current time < available date .

is there a $current_time or similar in prestashop or i must create one and if so where can i put the code for that?

Link to comment
Share on other sites

×
×
  • Create New...