Home > php教程 > php手册 > js操作时间

js操作时间

WBOY
Release: 2016-06-07 11:36:21
Original
966 people have browsed it

js获取当前时间,指定时间的时间戳
function transdate(endTime){
var date=new Date();
date.setFullYear(endTime.substring(0,4));
date.setMonth(endTime.substring(5,7)-1);
date.setDate(endTime.substring(8,10));
date.setHours(endTime.substring(11,13));
date.setMinutes(endTime.substring(14,16));
date.setSeconds(endTime.substring(17,19));
return Date.parse(date)/1000;
}
alert(transdate('2015-11-30 17:45:00'));// 指定时间的时间戳

var date =new Date();
var currenttime = Date.parse(date)/1000;
alert(currenttime );// 当前时间的时间戳

AD:真正免费,域名+虚机+企业邮箱=0元

source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template