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)。所有其他人都由引擎決定是否支持。 –