时间戳与时间的转化

时间戳转化为时间:

$scope.getLocalTime = function (n) {
        return new Date(n).toLocaleDateString();
};

时间转化为时间戳:

var date = new Date(); // 当前时间
console.log(date.getTime());
var d2 = new Date(2018,4,23);
console.log(d2.getTime());

 

posted @ 2018-04-23 17:06  五集麻辣油  阅读(126)  评论(0编辑  收藏  举报