Welcome 微信登录

首页 / 脚本样式 / JavaScript / JS 日期与时间戮相互转化的简单实例

1、日期格式转时间戮
function getTimestamp(time){ return Date.parse(new Date(time)); }
2、时间戮转日期格式
function transformPHPTime(time) {    var date = new Date(time * 1000);    Y = date.getFullYear() + "-";    M = (date.getMonth()+1 < 10 ? "0"+(date.getMonth()+1) : date.getMonth()+1) + "-";    D = date.getDate() + " ";    h = date.getHours() + ":";    m = date.getMinutes() + ":";    s = date.getSeconds();    return Y+M+D+h+m+s;}
以上就是小编为大家带来的JS 日期与时间戮相互转化的简单实例全部内容了,希望大家多多支持脚本之家~