JS Date String Parse

Source: Internet
Author: User

        function Dateparse (dstr) {                //var dstr = ' 2016-1-26 0:7:14 ';                var d = dstr.split (') [0].split ('-');                 var t = dstr.split (') [1].split (': ');                 var date =  new date (d[0],d[1]-1,d[2],t[0],t[1],t[2]);                 return date;        }

API Documentation Notes:

dateObj = new Date(year, month, date[, hours[, minutes[, seconds[,ms]]]])

Year

Required option. The full year, for example, 1976 (instead of 76).

Month

Required option. Represents the month, which is an integer from 0 to 11 (January to December).

Date

Required option. Represents a date, which is an integer from 1 to 31.

Hours

Options are available. If minutes is provided, it must be given. Represents the hour, which is an integer from 0 to 23 (midnight to 11pm).

Minutes

Options are available. If seconds is provided, it must be given. Represents the minute, which is an integer from 0 to 59.

Seconds

Options are available. If milliseconds is provided, it must be given. Represents the second, which is an integer from 0 to 59.

Ms

Options are available. Represents milliseconds, which is an integer from 0 to 999.

JS Date String Parse

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.