JS Date Object Date and parameter

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.