PDA

View Full Version : Display Current Time - The Eternal Question



artane
August 23rd, 2003, 12:19 PM
Hi guys,

I've got this code that displays the time but, I want the time to display dynamically, updated by the user's sytem clock so it always displays the "current time".

myNow=new Date();
myDay=myNow.getDay();
myMonth=myNow.getMonth();
myDate=myNow.getDate();
myHours=myNow.getHours();
myMinutes=myNow.getMinutes();
mySeconds=myNow.getSeconds();
myYear=myNow.getFullYear();
theHour=myHours
noon=""
if (myHours>=13){
theHour=myHours-12;
}
else {theHour==myHours;
}
if (myMinutes<10){
myMinutes="0"+myMinutes;
}

if (myHours<12){
noon="am";
}
else {
noon="pm"
}

theDay=new Array("Sunday","Monday", "Tuesday", "Wednesday","Thursday", "Friday", "Saturday");
theMonth=new Array("January","February","March","April","May","June","July","August","September","October","November","December");


theDate=theDay[myDay]+"\n"+myDate+" "+theMonth[myMonth]+", "+myYear+"\n"
+theHour+":"+myMinutes+" "+noon;



Any help would be greatly appreciated. Thank-You very much!

artane

Voetsjoeba
August 23rd, 2003, 12:29 PM
It does. Read this: http://www.macromedia.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary153.html

thoriphes
August 23rd, 2003, 12:29 PM
when you use the Date object, it will always use the user's local time if you use getDate, getHour, etc.

It will use the current time from the user's computer.