Var myDate = new Date (); myDate. getYear (); // obtain the current year (2 digits) myDate. getFullYear (); // obtain the complete year (4 digits, 1970 -????) MyDate. getMonth (); // obtain the current month (0-11, 0 represents January) myDate. getDate (); // obtain the current day (1-31) myDate. getDay (); // obtain the current day X (0-6, 0 represents Sunday) myDate. getTime (); // obtain the current time (milliseconds starting from 1970.1.1) myDate. getHours (); // obtain the current hour (0-23) myDate. getMinutes (); // get the current number of minutes (0-59) myDate. getSeconds (); // obtain the current number of seconds (0-59) myDate. getMilliseconds (); // get the current number of milliseconds (0-999) myDate. toLocaleDateString (); // obtain the current date var mytime = myDate. toLocaleTimeString (); // obtain the current time myDate. toLocaleString (); // obtain the date and time
Conversion Time Format String
Function getdate () {var now = new Date (); var y = now. getFullYear (); var m = now. getMonth () + 1; var d = now. getDate (); m = m <10? "0" + m: m; d = d <10? "0" + d: d; return y + "-" + m + "-" + d ;}