js setFullYear() toUTCString() getDay()实例教程
先看setFullYear() 实例:
<html>
<body>
<script type="text/javascript">
var d = new Date();
d.setFullYear(1992,10,3);
document.write(d);
</script>
</body>
</html>
结果.
Thu, 13 Nov 2008 08:32:43 UTC
toUTCString() 实例.
<html>
<body>
<script type="text/javascript">
var d = new Date();
document.write (d.toUTCString());
</script>
</body>
</html>
答案Thu, 13 Nov 2008 08:36:36 UTC
getDay ( )
使用getDay ( )和一个数组写一工作日,而不仅仅是一个数字。
<html>
<body>
<script type="text/javascript">
var d=new Date();
var weekday=new Array(7);
weekday[0]="Sunday";
weekday[1]="Monday";
weekday[2]="Tuesday";
weekday[3]="Wednesday";
weekday[4]="Thursday";
weekday[5]="Friday";
weekday[6]="Saturday";
document.write("Today it is " + weekday[d.getDay()]);
</script>
</body>
</html>
结果.
Today it is Thursday