解决IE报错:Locale 'chinese' is not well-formed,或RangeError: 区域设置“chinese”的格式不正确的问题
接之前的此博客问题处理:js处理时间时区问题
由于 toLocaleString():据本地时间格式,把 Date 对象转换为字符串。总是会带有上午/下午,所以我加了参数:new Date('2019-09-12 23:33:33').toLocaleString('chinese', {hour12: false}),这样返回的字符串就是24小时制,而没有上午下午。
但是,在IE浏览器下就会报标题的错误,期初不知道是什么原因,经过排查发现就是这个参数问题。
所以我们需要修改下:可以利用 toUTCString() 方法:根据世界时,把 Date 对象转换为字符串。
所以函数需要改下:
// 将实际时间转为世界标准时间
let _realTime = new Date(_time + ' GMT+0800').toUTCString()
let realTime = new Date(_realTime).getTime()
// 当前时间也转为世界标准时间
let _nowTime = new Date().toUTCString()
let nowTime = new Date(_nowTime).getTime() let diffValue = nowTime - realTime
即:先把服务器时间转为世界时,然后再把当前时间转为世界时,再计算差值,比较靠谱
解决IE报错:Locale 'chinese' is not well-formed,或RangeError: 区域设置“chinese”的格式不正确的问题的更多相关文章
- Idea使用记录--添加Problems&&解决Autowired报错could not autowire
今天在使用Idea的时候,发现Idea在整个每次找到错误代码非常不方便(Idea如果类中有错误,没有打开过类并不会提示,比如构建工程后缺少jar包问题).我想快速看到工程哪里出问题类似于eclipse ...
- [转]解决Maven报错"Plugin execution not covered by lifecycle configuration"
[转]解决Maven报错"Plugin execution not covered by lifecycle configuration" 导入Myabtis源码后,POM文件会报 ...
- 解决MySQL报错ERROR 2002 (HY000)【转】
今天在为新的业务线搭架数据库后,在启动的时候报错 root@qsbilldatahis-db01:/usr/local/mysql/bin# ./mysql ERROR 2002 (HY000): C ...
- vue解决启动报错cjs loader.js Error: Cannot find module '../config'问题
vue解决启动报错cjs loader.js Error: Cannot find module '../config'问题 今天下载了一个开源项目一直运行不了,折腾了半天才找到问题所在,config ...
- 解决 php 报错 open_basedir restriction in effect或者nginx提示No input file specified怎么办
解决 php 报错 open_basedir restriction in effect或者nginx提示No input file specified怎么办 问题是出现在了PHP.INI上面了 ,原 ...
- 解决MySQL报错:1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'informat
解决MySQL报错:1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'informat ...
- eclips中maven解决jsp报错的问题
加入如下的pom依赖: <!-- 解决jsp报错的依赖包第一个 --> <dependency> <groupId>javax.servlet</groupI ...
- 不修改系统日期和时间格式,解决Delphi报错提示 '****-**-**'is not a valid date and time
假如操作系统的日期格式不是yyyy-MM-dd格式,而是用strtodate('2014-10-01')) 来转换的话,程序会提示爆粗 '****-**-**'is not a valid date ...
- Git fetch和git pull的区别, 解决Git报错:error: You have not concluded your merge (MERGE_HEAD exists).
Git fetch和git pull的区别, 解决Git报错:error: You have not concluded your merge (MERGE_HEAD exists). Git fet ...
随机推荐
- 【SpringBoot】SpingBoot整合AOP
https://blog.csdn.net/lmb55/article/details/82470388 [SpringBoot]SpingBoot整合AOPhttps://blog.csdn.net ...
- spark-sql使用笔记
如何使用hive的udf 可以使用spark-sql --jars /opt/hive/udf.jar,指定udf的路径 还可以在spark-default.conf里指定spark.jars /op ...
- Fiddler-修改请求的上行参数
方法一:对所有的请求打断点 1.rules->automatic Breakpoints->Befor Requests 2.点击选择需要修改的请求 3.选择右侧请求区域的 Inspect ...
- pandas-11 TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely错误解决方法
pandas-11 TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be sa ...
- Spring Data Jpa 复杂查询总结
实体类 @Entity @Table(name = "t_hotel") @Data public class THotel { @Id private int id; priva ...
- SuperMap iServer之CAS单点登陆搭建流程
一.安装CAS 1.环境准备 cas-server-3.5.2-release.zip apache-tomcat-7.0.42.zip supermap_iserver_8.1.1a 2.安装CAS ...
- JWT生成token及过期处理方案
业务场景 在前后分离场景下,越来越多的项目使用token作为接口的安全机制,APP端或者WEB端(使用VUE.REACTJS等构建)使用token与后端接口交互,以达到安全的目的.本文结合stacko ...
- 使用focusky制作展示动画
一个协会要举办大会议,以前我帮着做了个图片视频,就是很多照片循环展示,配个背景音乐那种. 现在又找到我,我用focusky制作下,因很久不用,怎么使用也忘了,这个软件的操作逻辑也不太容易搞的清,主要是 ...
- golang面向对象实现
面向对象编程三大特点:封装.继承.多态. 1. 构造函数 Go不支持构造器.如果某类型的零值不可用,需要提供NewT(parameters)函数,用来初始化T类型的变量.按照Go的惯例,应该把创建T类 ...
- MySQL/MariaDB数据库的存储过程
MySQL/MariaDB数据库的存储过程 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.存储过程概述 1>.存储过程优势 存储过程把经常使用的SQL语句或业务逻辑封装起 ...