How JavaScript converts a time date to a Date object:
Sometimes you need to tell a string of time and date to convert to a date time object, the following is a simple example to provide a solution, of course, is a way of thinking, you can make some modifications to achieve extrapolate effect. For example, here is a time-date string:
2013-9-15 8:25:30
These are converted to time objects.
The code is as follows:
var timestr= "2013-9-15 8:25:30"; var strarray=timestr.split (""); var strdate=strarray[0].split ("-"); var strtime=strarray[1].split (":"); var timeobj=new Date (Strdate[0], (Strdate[1]-parseint (1)), strdate[2],strtime[0],strtime[1],strtime[2]) Console.log (Timeobj.getfullyear ())
The above code can output 2013, indicating that we have successfully converted the time-date string to the time object.
The original address is: http://www.softwhy.com/forum.php?mod=viewthread&tid=9184
JavaScript Conversion Date-qualified