jquery shows wrong date
This question already has an answer here:
You should check the manual:
getDay - method returns the day of the week for the specified date according to local time, where 0 represents Sunday
getMonth - An integer number, between 0 and 11, representing the month in the given date according to local time. 0 corresponds to January, 1 to February, and so on.
getYear - A number representing the year of the given date, according to local time, minus 1900
What you are actually looking for is:
<p id="date"></p>
<script>
var today = new Date();
var day = today.getDate();
var month = today.getMonth() + 1;
var year = today.getFullYear();
document.getElementById('date').innerHTML = day + "." + month + "." + year;
</script>
</html>
链接地址: http://www.djcxy.com/p/77526.html
上一篇: 我如何用变量表示当前时间?
下一篇: jquery显示错误的日期