Skip to content

Commit

Permalink
添加TZC方法,强制显示某时区时间
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Jun 22, 2015
1 parent 3bb5aa2 commit 73fbb36
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions date.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@
else result="刚刚";
return result;
}
/**
* [TZC 解决因时区变更,导致显示服务器时间不准确 time Zone Converter]
* @param {[type]} timeZone [时区]
*/
Date.prototype.TZC = function(timeZone){
var new_date = new Date(),
old_date = this.getTime();
return (isNaN(timeZone)&&!timeZone)? this : new Date(old_date + new_date.getTimezoneOffset() * 60 * 1000 + timeZone * 60 * 60 * 1000 );
}
/**
* [toHHMMSS 超过分钟以分钟为单位,超过小时以小时为单位]
* @param {[type]} format ["123112".toHHMMSS('hh时mm分ss秒')]
Expand Down

0 comments on commit 73fbb36

Please sign in to comment.