Date common API
Copy the code
getTime (); // milliseconds
getFullYear (); // Year
getMonth (); // months (0 to 11) to +1
getDate (); // day
getHours (); // hours
getMinutes (); // min
the getSeconds (); // sec
Date.now (); // current number of milliseconds
new Date (); // current time
1, the current time for the timestamp
var timestamp = parseInt (new Date ( ) getTime () / 1000.); // current timestamp
document.write (timestamp);
2、当前时间换日期字符串
var now = new Date();
var yy = now.getFullYear(); //年
var mm = now.getMonth() + 1; //月
var dd = now.getDate(); //日
var hh = now.getHours(); //时
var ii = now.getMinutes(); //分
var ss = now.getSeconds(); //秒
var clock = yy + “-”;
if(mm < 10) clock += “0”;
clock += mm + “-”;
if(dd < 10) clock += “0”;
clock += dd + " ";
if(hh < 10) clock += “0”;
clock += hh + “:”;
if (ii < 10) clock += ‘0‘;
clock += ii + “:”;
if (ss < 10) clock += ‘0‘;
clock += ss;
document.write(clock); //获取当前日期
3, transfer date stamp string
var DATE = '2015-03-05. 17: 59: 00.0';
DATE = date.substring (0,19);
DATE date.replace = (/ - / G, '/') ;
var = new new timestamp a Date (DATE) .getTime ();
document.write (timestamp);
4, transfer date stamp string
var timestamp = '1425553097';
var a Date new new D = (timestamp * 1000); // time stamp generator according to the object
var date = (d.getFullYear ()) + "-" +
(d.getMonth () +. 1) + "-" +
(d.getDate ()) + "" +
(d.getHours ()) + ":" +
(d.getMinutes ()) + ":" +
( d.getSeconds ());
document.write (DATE);
Acquisition time using built-in JavaScript Date function completion
var = MyDate new new Date ();
mydate.getYear (); // get the current year (2)
mydate.getFullYear (); // get the full year (4, 1970 - ???)
mydate.getMonth (); // get the current month (0-11,0 behalf January)
mydate.getDate (); // get the current day (1-31)
mydate.getDay (); // get the current week X (0-6,0 for Sunday)
mydate.getTime (); // get the current time (the number of milliseconds from the start 1970.1.1)
mydate.getHours (); // get the current number (0-23 hours )
mydate.getMinutes (); // get the current number of minutes (0-59)
mydate.getSeconds (); // get the current number of seconds (0-59)
mydate.getMilliseconds (); // get the current number of milliseconds (0- 999)
mydate.toLocaleDateString (); // get the current date
var mytime = mydate.toLocaleTimeString (); // get the current time
mydate.toLocaleString (); // get the date and time
Date Time script library list method
Analyzing Date.prototype.isLeapYear leap year
Date.prototype.Format formatted date
Date.prototype.DateAdd date calculation
Date.prototype.DateDiff comparison date difference
Date.prototype.toString transfer date string
Date.prototype.toArray array is divided into a date
Date. date information prototype.DatePart take part in
maximum number of days taken Date.prototype.MaxDayOfDate date where the month of
the week Date.prototype.WeekNumOfYear judgment date falls in
StringToDate transfer date string type
IsValidDate verify the validity date
CheckDateTime complete date and time of inspection
daysBetween date number of poles
Set the time
setFullYear: Set the year
setMonth: Sets the month
setDate: set a monthly one day
setHours: Set
setNubytes: Set points
setSeconds: Set seconds
setMilliseconds: Sets the milliseconds