JS Computing System The current date is the day of the week several ways

Source: Internet
Author: User

Method One:

// The calculation system is currently the day of the week var str = "Today is the Week" + "Day 123456". Charat (new date (). Getday ());

Method Two:

var new Array ("Day", "one", "two", "three", "four", "five", "six"); var New date (). Getday (); var str = "Today is the Week" + A[week];alert (str);

Method Three:

varstr = "Today is the Week";varWeek =Newdate (). Getday ();Switch(week) { Case0: str1+ = "Day";  Break;  Case1: str1+ = "One";  Break;  Case2: str1+ = "Two";  Break;  Case3: str1+ = "three";  Break;  Case4: str1+ = "Four";  Break;  Case5: str1+ = "Five";  Break;  Case6: str1+ = "Six";  Break;} alert (str);

Method Four:

varstr = "";varWeek =Newdate (). Getday ();if(Week = = 0) {str= "Today is Sunday";} Else if(Week = = 1) {str= "Today is Monday";} Else if(Week = = 2) {str= "Today is Tuesday";} Else if(Week = = 3) {str= "Today is Wednesday";} Else if(Week = = 4) {str= "Today is Thursday";} Else if(Week = = 5) {str= "Today is Friday";} Else if(Week = = 6) {str= "Today is Saturday";} alert (str);

Of course, the perfection of these four methods is at a glance.

JS Computing System The current date is the day of the week several ways

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.