0
我的日期选择器甲酸日期=月-21-2014 11:00 AM日期解析问题在javascript
我想日期选择器转换为时间戳甲像2014-07-21T11:00:00。在JavaScript中。
为此,我已经写的
var now = new Date(date);
var year = now.getFullYear();
var month = now.getMonth()+1;
var day = now.getDate();
var hour = now.getHours();
var minute = now.getMinutes();
var second = now.getSeconds();
var convertedDate = year+'-'+month+'-'+day+'T'+hour+':'+minute+':'+second;
它的工作在Chrome和Firefox罚款,但它未能在互联网探索。
我得到的日期值像NaN-NaN-NaNTNaN:NaN:NaN。
请帮忙。如何解决这个问题?
看到:: http://stackoverflow.com/questions/2182246/javascript-dates-in-ie-nan-firefox-chrome-ok –
对于自定义格式一致的行为,可能需要找到提供“精确解析”或“采用格式解析”选项的库。 JavaScript只有[一种指定的日期/时间格式](http://ecma-international.org/ecma-262/5.1/#sec-15.9.1.15)。所有其他人都由引擎决定是否支持。 –