我的日期功能不适用于Firefox,但适用于Chrome

时间:2019-06-27 10:29:41

标签: reactjs date

我在我的React代码中使用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);

alert(getnewdate);在正确的Chrome上显示“星期二2019年6月25日00:00:00 GMT + 0530(印度标准时间)”,但在Firefox上显示不正确的“无效日期”。

我希望我的警报功能在Firefox和chrome中都能正常工作。

1 个答案:

答案 0 :(得分:0)

使用yyyy/MM/dd(you can have any format of date) HH:mm:ss(this is required)格式的日期,它将在所有浏览器中都有效,

var getselectdate = "Jun-27-2019 12:00:00";