Today is the day of the week.

Source: Internet
Author: User
Method 1: [javascript] varstr & quot; varweeknewDate () getDay (); if (week0) {str & quot; today is Sunday & quot ;;} elseif (week1) {str & quot; today is Monday & quot; the first method is to write [javascript] var str = ""; var week = new Date (). 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";} name = "code" class = "javascript"> alert (str );The second statement is written in [javascript] var str = "Today is the week"; var week = new Date (). getDay (); switch (week) {case 0: str + = ""; break; case 1: str + = "1"; break; case 2: str + = "2"; break; case 3: str + = "3"; break; case 4: str + = "4"; break; case 5: str + = "5"; break; case 6: str + = "6"; break;} alert (str ); method 3: [javascript] var a = new Array ("day", "one", "two", "three", "four", "five ", "6"); var week = new Date (). getDay (); var str = "Today is the week" + a [week]; alert (str ); the last method is [javascript] var str = "Today is the week" + "May 15, 1234 ". charAt (new Date (). getDay (); alert (str );
Related Article

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.