我想用jQuery在网页上显示这个。。。
2011年8月12日星期五
我有一个带有日期设置ID的div,我想将其打印到其中。
Jquery到目前为止。。
var newDate = new Date();
newDate.setDate(newDate.getDate() + 1);
$('#Date').html((newDate.getMonth() + 1) + '/' + newDate.getDate() + '/' + newDate.getFullYear());
有人能告诉我如何正确地格式化吗?
最佳答案
var monthNames = [ "January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December" ];
var dayNames= ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]
var newDate = new Date();
newDate.setDate(newDate.getDate() + 1);
$('#Date').html(dayNames[newDate.getDay()] + " " + newDate.getDate() + ' ' + monthNames[newDate.getMonth()] + ' ' + newDate.getFullYear());
工作演示-http://jsfiddle.net/ipr101/X9hyZ/