范文 |
下面小编就为大家带来一篇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 日期与时间戮相互转化的简单实例全部内容了
|