js the current processing time


// . 1, the number of days between the JS obtaining difference between two dates 2 function getDaysBetween (dateString1, dateString2) { . 3 var startDate = Date.parse (dateString1); . 4 var endDate = Date.parse (dateString2); . 5 var Days = ( endDate - startDate) / (. 1 * 24 * 60 * 60 * 1000 ); . 6 // Alert (Days); . 7 return Days; . 8 } . 9 // 2, acquires the current time is the JS year or month 10 var myDate = new new a Date (); . 11 myDate.getYear (); // get the current year (2) 12myDate.getFullYear (); // get the full year (4, 1970 - ????) 13 myDate.getMonth (); // Get the current month (0-11,0 behalf January) 14 myDate.getDate ( ); // get the current day (1-31) 15 myDate.getDay (); // get the current week X (0-6,0 for Sunday) 16 myDate.getTime (); // get the current time (from 1970.1. starting a number of milliseconds) . 17 myDate.getHours (); // get the current number (0-23) h 18 is myDate.getMinutes (); // get the current number (0-59) minutes . 19 myDate.getSeconds (); / / Get the current second (0-59) 20 is myDate.getMilliseconds (); // get the current number of milliseconds (0-999) 21myDate.toLocaleDateString (); // get the current date 22 is var MyTime = myDate.toLocaleTimeString (); // get the current time 23 is myDate.toLocaleString (); // get the date and time

// more time formatting moment.js

Guess you like

Origin www.cnblogs.com/jia-ze/p/12130812.html