JS Convert time to Timestamp

Source: Internet
Author: User
Tags local time

1 varChangetimes =function(time) {2         vartemp = time.split (' ');3         vararr = Temp[0].split ('-');4         varBRR = Temp[1].split (': '));5         if(Brr.length = = 3){6             vartimestamp =NewDate (DATE.UTC (arr[0], arr[1]-1, arr[2], +brr[0]-8, brr[1], brr[2]));7}Else if(Brr.length = = 2){8             vartimestamp =NewDate (DATE.UTC (arr[0], arr[1]-1, arr[2], +brr[0]-8, brr[1]));9         }Ten         vartimestamp = Timestamp.gettime ()/1000; One         returntimestamp; A};

DATE.UTC function (JavaScript)

Returns the number of milliseconds between midnight of January 1, 1970 Coordinated Universal Time (UTC) (or GMT) and the specified date.

Grammar:

Notes

DATE.UTCThe function returns the number of milliseconds from midnight UTC January 1, 1970 to the provided date. If the parameter value is greater than its range or is negative, the other stored values will be modified accordingly.   

The difference between the date.utc function and the Date object constructor that accepts dates is that thedate.utc function takes UTC, and the date object constructor takes local time.

JS Convert time to Timestamp

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.