用js将毫秒时间转成正常时间

1. 将毫秒时间转成正常时间

 1 //#region 将毫秒转换成正常的日期
 2         function getDate(time) {
 3             var date = new Date(parseInt(time));
 4 
 5             var mouth = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : (date.getMonth() + 1);
 6             var currentDate = date.getDate() < 10 ?("0"+date.getDate()):(date.getDate());
 7            
 8             return date.getFullYear() + "/" + mouth + "/" + currentDate;
 9         }
10 //#endregion
将毫秒时间转成正常时间

 

2. 将正常时间转成毫秒时间

1 function getMTime(dat) {
2             //dat的格式-->"2014/03/08 17:55:49"
3             return new Date(dat).getTime();
4         }
将正常时间转成毫秒时间

 

posted @ 2014-03-09 17:20  李亚杰  阅读(268)  评论(0编辑  收藏  举报