The Date object is used to process dates and times.
var mydate=New Date ()
The Date object automatically saves the current date and time as its initial value.
The common methods of date are:
Mydate.getyear ();//get Current year (2-bit)Mydate.getfullyear ();//Get the full year (4-bit, 1970-????)Mydate.getmonth ();//Get the current month (0-11, 0 for January)Mydate.getdate ();//get current day (1-31)Mydate.getday ();//get Current week x (0-6, 0 for Sunday)Mydate.gettime ();//Gets the current time (the number of milliseconds since 1970.1.1)Mydate.gethours ();//gets the current number of hours (0-23)Mydate.getminutes ();//gets the current number of minutes (0-59)Mydate.getseconds ();//gets the current number of seconds (0-59)
JS Gets the current timestamp method-javascript Gets the current timestamp
The first method:
var timestamp =date.parse (New Date ());
Results: 1280977330000
The second method:
var timestamp = (new Date ()). ValueOf ();
Results: 1280977330748
The third method:
var timestamp=new Date (). GetTime ();
Results: 1280977330748
The first: The time stamp obtained is the change of milliseconds to 000 display,
The second and third is to get the timestamp of the current millisecond.
get a total of how many days this month
var New Date (5,0). GetDate ();
Get what number after 20 days
var New Date (5, + +).GetDate ()
The date in JavaScript