Javascript-Month-day conversion 12-hour system

Source: Internet
Author: User

1<! DOCTYPE html>234<meta charset= "UTF-8" >5<title></title>67<body>8<script>9     functionFormat (date) {Ten         //defining Arrays week:[Day, one, two, three, four, five, six] One         varWeek=["Day", "one", "two", "three", "four", "five", "six"]; A         //get the year y in date -         vary=date.getfullyear (); -         //get the month m in date, and then +1 the         varM=date.getmonth (+1); -         //if m<10, change to 0+m; -m<10&& (m= "0" +M); -         //Get Day D +         varD=Date.getday (); -         //if d<10, just the bit 0+d +d<10&& (d= "0" +d); A         //Get Week Day at         varday=Date.getday (); -         //get Chinese characters from day position in week save back to day -day=Week[day]; -         //Get hours H -         varH=date.gethours () -         //To define the variable am, assign the value: in         varAm=h<12? " Morning ":" Afternoon "; -         //if h<12, assign value to morning, otherwise assign to PM to         //will h-12 +H-=12; -         //if h<10, change to 0+h theh<10&& (h= "0" +h); *         //Get minutes M $         varm=date.getminutes ();Panax Notoginseng         //get the minute m<10 and change to 0+m -m<10&& (m= "0" +m); the         returny+ "Year" +m+ "month" +d+ "Day Week" +day+ "" +am+h+ ":" +m; +         //September 01, 2016 Thursday morning 11:57 A     } theConsole.log (Format (NewDate ())); +</script> -</body> $

Javascript-Month-day conversion 12-hour system

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.