Howto
Download the above script, rename it as spip_localtime_en.js, upload it to the root directory of your server and write the following code in the HEAD section of your templates :
<script language="JavaScript" type="text/javascript" src="spip_localtime_en.js"></script>Then, paste this code in yoyr mes_fonctions.php3 file :
function localtime_js($date, $format = "Y-m-d H:i:s") {
return "<script language=\"JavaScript\" type=\"text/javascript\">s_lt(".strtotime($date).", '".str_replace('\\', '\\\\', $format)."');</script><noscript>".date($format, strtotime($date))." UTC</noscript>";
}Eventually, place this code in your templates :
[(#DATE|localtime_js{'y-m-d H:i'})]This date format between brackets is quite the same as function date in PHP. The supported codes are : d, F, G, H, i, j, l, m, n, s, Y and y. It also supports anti-slashes to escape characters.
Limits
Server timezone needs to be UTC (or the script needs some modifications).
If the browser doesn’t support JavaScript, date and time are displayed in UTC.




spip_localtime_en.txt
Vos commentaires
# Le 3 décembre 2007 à 09:18, par Eduardo Rojero
Hi. My server has NY’s time. I’m in Mexico (a two hours difference).
What kind of modifications should I do by using your js script ?
I’m not to php savvy.
Thanks ! This is my site : www.elagoradechihuahua.com
Répondre à ce message