OT - Quick JavaScript Question
| From: | Jake McHenry | Date: | Tue, 28 Oct 2003 19:10:15 +0000 |
| Subject: | OT - Quick JavaScript Question | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-167909@lists.php.net to get a copy of this message | ||
I know this is a bit off topic, but does anyone know of a way I can take the server time in php and
get it into javascript? here is the code so far for my javascript clock, but it uses the clients
time. I either need to replace the Date() function with another, or somehow import php's time.
I have the time from the server in $LogInOutHours:$LogInOutMinutes:$LogInOutSeconds $LogInOutAmPm
Thanks,
Jake
function startclock()
{
var thetime=new Date();
var nhours=thetime.getHours();
var nmins=thetime.getMinutes();
var nsecn=thetime.getSeconds();
var AorP=" ";
if (nhours>=12) AorP="PM";
else AorP="AM";
if (nhours>=13) nhours-=12;
if (nhours==0) nhours=12;
if (nsecn<10) nsecn="0"+nsecn;
if (nmins<10) nmins="0"+nmins;
document.timesheet.time.value = nhours+":"+nmins+":"+nsecn;
document.timesheet.ampm.value = AorP;
setTimeout('startclock()',1000);
}