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