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.
Aucune discussion
Ajouter un commentaire
Avant de faire part d’un problème sur un plugin X, merci de lire ce qui suit :
Merci d’avance pour les personnes qui vous aideront !
Par ailleurs, n’oubliez pas que les contributeurs et contributrices ont une vie en dehors de SPIP.
Suivre les commentaires : |