javascript当中Date对象用法

2.Date对象

例 2.1

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<Script>
/*马克-to-win:Global有个Date()这个方法。*/
 /*When the Global object is created, it always has at least the following properties:
       Object object       Function object       Array object       String object
       Boolean object       Number  object       Date object       Math object
       Value properties
   */
    var today = new Date();
    var month = today.getMonth()+1;
    var date  = today.getDate();
    var day   = today.getDay();
    document.write("今天是");
    document.write(month+"月");
    document.write(date+"日");
    document.write("星期"+day);//注意:是阿拉伯数字并非中文;请试改为中文习惯
    var s="调试站位";
</Script>
</head>
<body>

详见:http://www.mark-to-win.com/index.html?content=Javascript/jsUrl.html&chapter=Javascript/js2_web.html#DateObject

猜你喜欢

转载自blog.csdn.net/mark_to_win/article/details/88621171