Blogger Information
Blog 47
fans 0
comment 2
visits 102654
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
js时区转换并计算时间
拾一枝樱花的博客
Original
2741 people have browsed it
  1. 获取客户端的时区并计算当前时间
  2. function formatDate(strDate) {
  3. var timeZone = (new Date().getTimezoneOffset()) * 60 * 1000;
  4. var len = new Date(strDate).getTime();
  5. var date2 = new Date(len - timeZone);
  6. return date2.getFullYear() + "/" + (p(date2.getMonth() + 1)) + "/" + p(date2.getDate()) + ' ' + p(date2.getHours()) + ':' + p(date2.getMinutes()) + ':' + p(date2.getSeconds());
  7. }
  8. 双位小于10前面补0
  9. function p(s) {
  10. return s < 10 ? '0' + s: s;
  11. }
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post