date.UTC的结果和其他可能存在时差,需要进行一些处理

 14 //普通时间toUNIX时间
 15 function get_unixtime(str)
 16 {
 17     str = str.replace(/-/g, "/");
 18     var date = new Date(str);
 19     var unixtime = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(),
 20                 date.getHours(), date.getMinutes(), date.getSeconds()));
 21 
 22     //unixtime 为当前UTC时间距离1970/01/01 00:00:00的毫秒数
 23     return unixtime.getTime()/1000 + date.getTimezoneOffset()*60;
 24 }

 

posted on 2013-05-13 15:43  NKHe!!oWor!d  阅读(399)  评论(0编辑  收藏  举报