我有這個日期在這裏2013/06/10,它來自數據庫,並設置在一個變量稱爲日期。Javascript ...添加一天到目前爲止,並更改格式
我做這個加有一天這個日期..
var endDate = new Date(date);
endDate.setDate(endDate.getDate() + 1);
,現在我試圖改變格式YYYY/MM/DD
var finalEndDate = endDate.toString('yyyy/MM/dd');
alert(finalEndDate);
但這返回
2013年6月11日東部標準時間等
我該如何解決這個問題?
如果您使用的是jQuery,請考慮使用此插件:http://www.datejs.com/ – Learner
endDate.toString('yyyy,MMMM,dddd') – Supplement
http://stackoverflow.com/q/的重複項1056728 /。簡而言之,['Date'的'.toString()'](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toString)不接受參數。您需要使用'getMonth()'等手動格式化它,或者找到一個庫來格式化超出'toString()','toLocaleString()'等的日期。[Moment.js](http:// momentjs .com /)是一個普遍的建議,仍處於積極的發展階段。 –