


JavaScript method to convert date string into Date date object_javascript skills
May 16, 2016 pm 04:14 PMThe example in this article describes the method of converting a date string into a Date object using JavaScript. Share it with everyone for your reference. The details are as follows:
Here is how to convert a date string such as "2014-4-28 12:31:45" into a Date object:
Method 1:
var strDate=strArray[0].split("-");
var strTime=strArray[1].split(":");
var a=new Date(strDate[0],(strDate[1]-parseInt(1)),strDate[2],strTime[0],strTime[1],strTime[2])
Method 2 (super simple):
var d = new Date(Date.parse(s.replace(/-/g, "/")));
I hope this article will be helpful to everyone’s JavaScript programming design.

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to write a novel in the Tomato Free Novel app. Share the tutorial on how to write a novel in Tomato Novel.

How to recover deleted contacts on WeChat (simple tutorial tells you how to recover deleted contacts)

Practical tips for converting full-width English letters into half-width form

Quickly master: How to open two WeChat accounts on Huawei mobile phones revealed!

The secret of hatching mobile dragon eggs is revealed (step by step to teach you how to successfully hatch mobile dragon eggs)

How to set font size on mobile phone (easily adjust font size on mobile phone)

How to convert qq music to mp3 format Convert qq music to mp3 format on mobile phone

The difference between Go language methods and functions and analysis of application scenarios
