Create a Date object, Date object can be passed parameter
new Date () Create Date Object
getFullYear () get year
GetMonth () Gets the month return value is an integer between 0 (January) and 11 (December)
Getda Te () Get date (number of numbers)
GetDay () Gets the number of weeks the return value is an integer between 0 (Sunday) and 6 (Saturday).
GetHours () Gets the hour return value is an integer between 0 (midnight) and 23 (11 o'clock in the night)
Getminutes () Gets the number of minutes the return value is an integer between 0 and 59
Getseconds () Gets the number of seconds returned The value is an integer between 0 and 59,
GetTime () returns the number of milliseconds from January 1, 1970 to G MT time
Date parameter returns Wed Dec 22:41:04 gmt+0800 (China Standard Time) There are two types of object
arguments: Numeric type and String type
parameter in the form of the following 5
New Date ("Month dd,yyyy hh:mm:ss");
New Date ("Month dd,yyyy");
New Date (YYYY,MTH,DD,HH,MM,SS);
New Date (YYYY,MTH,DD);
New Date (MS);
need to be aware of the last form, which represents the number of milliseconds between the time that needs to be created and the GMT time of January 1, 1970
Number form: New Date (2016,10,26,22,17,20)
String form: New Date ()
Month English word January February March April May June July August September October November December
Time conversion formula (T is number of seconds)
Days: Math.floor (t/86400)
: Math.floor (t%86400/3600)
: Math.floor (T%86400%3600/60)
seconds: Math.floor (t%60)
For example:
var inow = new Date (); Wed Dec 22:41:04 gmt+0800 (China Standard Time)
var iNew = new Date (2016,11,21,22,29,0);
var iNew = new Date ("December 21,2016 22:39:00");
var t = Math.floor ((inew-inow)/1000); milliseconds, seconds
JS Date Object Date and parameter