Why does this Javascript not work in Firefox?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to manipulate a date with some simple Javascript. The code is as follows: var newDate = new Date("2013-07-23" + " 12:00:00"); console.log(newDate.toString()); newDate = new Date(newDate.getTime() - (24 * 60 * 60 * 1000)); console.log(newDate.toString()); var date = newDate.getFullYear() + "-" + ("0" + (newDate.getMonth() + 1)).slice(-2) + "-" + ("0" + newDate.getDate()).slice(-2); console.log(date); Essentially, I am converting 2013-07-23 -> Jul 22 2013 12:00:00 GMT+1000 -> 2013-07-22 It works fine in Chrome, you can test the