17, date and time
1. Clock example (Clock Example)
Q: How do I write a clock program using JavaScript?
A : A simple clock program is to get a new date (or, better, a few times a second) per second, and then display the time information from the date () object. The following code shows a clock in the browser's status bar:
function Sbclock () {
var datestring= (new Date ()). ToString ();
Self.status=datestring.substring (0,3+datestring.lastindexof (': '));
SetTimeout ("Sbclock ()");
Sbclock ();
2. Calendar example (Calendar Example)
Q: How to determine the day of the week by a given date.
A: to determine the day of the week from a given date, you can set this date to a date () object and then obtain the day of the week via Date.getday ():
D=new Date (); D.setdate (1);
D.setyear (yyyy);
D.setmonth (mm);
D.setdate (DD);
Ww=d.getday ();
if (ww==0) wday= "Sunday";
if (ww==1) wday= "Monday";
if (ww==2) wday= "Tuesday";
if (ww==3) wday= "Wednesday";
if (ww==4) wday= "Thursday";
if (ww==5) wday= "Friday";
if (ww==6) wday= "Saturday";
3.2000 issue (Year Problem)
This is a discussion about the millennium bug problem, now 2000 has been in the past for a long time, this is no longer there. Interested can click on the link directly to view the original.