Date Type method

Source: Internet
Author: User

Date method function

Date.parse (): The number of milliseconds that the date can be obtained

var now=date.parse (' May 25,2005 ')//1085414400000

DATE.UTC (): You can also get the milliseconds of the time, but the parameters are different (2005,4,5) is the May 5, 2005, the base of the month is 0

var utc=date.utc (2000,3,4)//945806400000

New Date ()//The value returned is

var time1=new Date ()//tue June 10:37:07 gmt+0800 (CST)

var time2=time1.tolocalstring ()//2016/6/14 10:37:07

var time3=time1.tostring ()//tue June 10:37:07 gmt+0800 (CST)

var time4=time1.valueof ()//1465871827184 returns the number of milliseconds

var time5=time1.todatestring ()//tue June 14 2016

var time6=time1.totimestring ()//10:37:07 gmt+0800 (CST)

var time7=time1.tolocaledatestring ()//2016/6/14

var time8=time1.tolocaletimestring ()//10:35:13

var time9=time1.toutcstring ()//tue, June 02:36:36 GMT

PS: I personally think that the front-end words to use the date to achieve the JS function should be tolocaldatestring () method haha

var time10=time1.gettime ()//1465871827184 as with valueof ()

var time11=time1.getfullyear ()//2016

var time12=time1.getmonth ()//May starting from 0 0 for January

var time13=time1.getdate ()//14

var time14=time1.getday ()//2 back today Sunday today is Tuesday

var Time15=time1.gethousrs ()//10 because now is the hour number of 10 point return time

var time16=time1.getminutes ()//49 The current time is 10:49 minutes

var time17=time1.getseconds ()//9

Personally think these functions are more practical a little bit haha there are some ways not to study

Date Type method

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.