jQuery在网页上显示日期 [英] jQuery Display Date on Webpage
本文介绍了jQuery在网页上显示日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用jQuery在网页上显示它...
I want to display this on a webpage using jQuery...
2011年8月12日,星期五
Friday 12 August 2011
我有一个带有日期设置ID的div,我想将其打印到其中.
I have a div with an ID of date setup that I would like to print it into.
到目前为止的jQuery.
Jquery so far..
var newDate = new Date();
newDate.setDate(newDate.getDate() + 1);
$('#Date').html((newDate.getMonth() + 1) + '/' + newDate.getDate() + '/' + newDate.getFullYear());
有人可以告诉我如何正确格式化吗?
Can someone tell me how to format this correctly?
推荐答案
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/
这篇关于jQuery在网页上显示日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文