JavaScript FAQ (20)--Date and time __java

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.