reactjs - 我的日期功能不适用于 Firefox,但适用于 chrome
问题描述
我在我的反应代码中使用 Date() 函数。日期函数在 chrome 上运行良好,但在 Firefox 上运行。
我试图以毫秒为单位转换日期。
var getnewdate = "Wed Jun 26 2019 00:00:00 GMT+0530 (India Standard Time)";
alert(getnewdate);
var getCurrentDayInMilli = new Date(getnewdate).getTime() / 100000;
alert(getCurrentDayInMilli);
警报(getnewdate);在 chrome 上打印“Tue Jun 25 2019 00:00:00 GMT+0530 (India Standard Time)”是正确的,但在 Firefox 上打印的是“Invalid Date”,这是不正确的。
我希望我的警报功能在 Firefox 和 chrome 中都能正常工作。
解决方案
以这种格式使用日期yyyy/MM/dd(you can have any format of date) HH:mm:ss(this is required)
,这将适用于所有浏览器,
var getselectdate = "Jun-27-2019 12:00:00";
推荐阅读
- android - Daniel Gindi 的图表库 - 为图表数据添加趋势线?
- reactjs - React native 响应原生 web
- docker - Hyperledger Fabric peer 显示错误:“listen tcp 127.0.0.1:9443: bind: address already in use”但仅在使用 docker-py 时
- svelte - 使用 Sveltekit 刷卡:没有“刷卡”
- machine-learning - K-最近邻算法给出不合适的错误
- python - 为什么“NONE”被附加到列表中?
- reactjs - 错误:expect(jest.fn()).toHaveBeenCalledTimes(expected)
- sql - ORACLE SQL:减去两个或多个连续行的日期
- flutter - share_plus 不共享文字flutter
- webkit - 使用 webkit 的剧作家无法加载资产