GVR*_*GVR 2 javascript firefox internet-explorer
如何在JS中将字符串转换为时间戳和日期。这里使用的是Date.parse(),但在IE和FF中不起作用。我的代码是..
在镀铬中可以正常工作。
var str = "05-Sep-2013 01:05:15 PM ";
console.log( Date.parse( str ) );
console.log( Date.parse( str.replace(/-/g, '/') ) ); // 1378404315000
Run Code Online (Sandbox Code Playgroud)
在IE中返回
console.log( Date.parse( str.replace(/-/g, '/') ) ); // NaN
Run Code Online (Sandbox Code Playgroud)
请帮我。提前致谢。
不要将'-'替换为'/',而应使用空格。
var str = "05-Sep-2013 01:05:15 PM ";
console.log( Date.parse( str.replace(/-/g, ' ') ) );Run Code Online (Sandbox Code Playgroud)
在IE中对我有用
看看w3schools-他们正在使用空白:)
| 归档时间: |
|
| 查看次数: |
4310 次 |
| 最近记录: |