Have you changed:
$config['use_smarty_php_tags'] = true; <-- must be true
in your config.php?
Nullig
Display Server Time
-
- Forum Members
- Posts: 63
- Joined: Tue Nov 28, 2006 9:33 pm
Re: Display Server Time
I do not want the PM or AM into my clock just a nice 24 hour clock.
Code: Select all
<__script__ type="text/javascript">
<!--
function clock() {
document.write('<span id="lclock"></span>');
// here's the PHP code that spawn out the server local time
<?php list($sy,$sm,$sd,$sh,$si,$ss) = explode(",", date("Y,n,j,G,i,s"));
?>
// now we represent the server time as javascript date
var server = new Date(<?=$sy?>, <?=$sm?>, <?=$sd?>, <?=$sh?>, <?=intval($si)?>, <?=intval($ss)?>).getTime();
// calculate the client time
var client = new Date().getTime();
// run our ticker
tick(client-server);
}
function tick(diff) {
var d = new Date(new Date().getTime()-diff);
var i = d.getMinutes(); if(i < 10) i='0'+i;
var s = d.getSeconds(); if(s < 10) s='0'+s;
var lclock = document.getElementById("lclock");
if(lclock) {
lclock.innerHTML='De lokale tijd is '+
d.getHours()+':'+i+':'+s+' <?=$sa?>';
setTimeout('tick(' + diff + ');', 1000);
}
}
//-->
</__script>
Last edited by Oscar Luijben on Wed Jul 18, 2007 11:10 am, edited 1 time in total.
Re: Display Server Time
I've made another server's clock snippet, but using User Defined Tags instead.
Create a new UDT, let's name it 'show_clock', then enter the code below:
Now, to use it, just put {show_clock} tag in your page/template.
Create a new UDT, let's name it 'show_clock', then enter the code below:
Code: Select all
list($sy,$sm,$sd,$sh,$si,$ss) = explode(",", date("Y,n,j,G,i,s"));
$isi = intval($si);
$iss = intval($ss);
$host = $_SERVER['HTTP_HOST'];
echo <<< JSClock
<__script__ type="text/javascript">
<!--
function clock() {
document.write('<span id="clock"></span>');
// here's the PHP code that spawn out the server local time
// now we represent the server time as javascript date
var server = new Date($sy, $sm, $sd, $sh, $isi, $iss).getTime();
// calculate the client time
var client = new Date().getTime();
// run our ticker
tick(client-server);
}
function tick(diff) {
var d = new Date(new Date().getTime()-diff);
var i = d.getMinutes(); if(i < 10) i='0'+i;
var s = d.getSeconds(); if(s < 10) s='0'+s;
var month_names = ',Januari,Februari,Maret,April,Mei,Juni,Juli,Agustus,September,Oktober,November,Desember'.split(/,/g);
var clock = document.getElementById("clock");
if(clock) {
clock.innerHTML='Server: $host Time: '+
d.getDate()+'/'+month_names[d.getMonth()]+'/'+d.getFullYear()+' '+
d.getHours()+':'+i+':'+s;
setTimeout('tick(' + diff + ');', 1000);
}
}
clock();
//-->
</__script>
JSClock;