JavaScript Reference/Javascript Objects/Date

Материал из Web эксперт
Перейти к: навигация, поиск

"Date" Example

    
<html>
<body>
<script language="javascript">
function myFunction(){
    var date = new Date(); 
    alert(date.toString());
}
</script>
<button onclick="myFunction();">Today"s date</button>
</body>
</html>



"Date" JavaScript Methods

+----------------+--------------------------------------------------------------+
| JavaScript     |getDate                         getDay                        |
| Methods        |getFullYear                     getHours                      |
|                |getMilliseconds                 getMinutes                    |
|                |getMonth                        getSeconds                    |
|                |getTime                         getTimezoneOffset             |
|                |getUTCDate                      getUTCDay                     |
|                |getUTCFullYear                  getUTCHours                   |
|                |getUTCMilliseconds              getUTCMinutes                 |
|                |getUTCMonth                     getUTCSeconds                 |
|                |getYear                         parse                         |
|                |setDate                         setFullYear                   |
|                |setHours                        setMilliseconds               |
|                |setMinutes                      setMonth                      |
|                |setSeconds                      setTime                       |
|                |setUTCDate                      setUTCFullYear                |
|                |setUTCHour                      setUTCMilliseconds            |
|                |setUTCMinutes                   setUTCMonth                   |
|                |setUTCSeconds                   setYear                       |
|                |toGMTString                     toLocaleString                |
|                |toSource                        toString                      |
|                |valueOf                                                       |
+----------------+--------------------------------------------------------------+



"Date" JavaScript Properties

+----------------+--------------------------------------------------------------+
| JavaScript     |constructor                                                   |
+----------------+--------------------------------------------------------------+



"Date" Syntax and Note

Note:
Perform date computations.
    
Syntax:
    
var dateName = new Date(value) // value is empty or a date string
dateName.memberName