Home >Web Front-end >JS Tutorial >js converts the current time format into time (self-written)_javascript skills

js converts the current time format into time (self-written)_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:21:111040browse

A method I wrote myself

Copy the code The code is as follows:

function split_time(time){/ /Convert the current time to time, for example, 2013-09-11 12:12:12
var arr=time.split(" ");
var day=arr[0].split("-") ;
var hour=arr[1].split(":");
return Date.UTC(day[0],(day[1]-1),day[2],hour[0] ,hour[1],hour[2])/1000; //Convert the current time into time
}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn