HTML and CSS Reference
In-Depth Information
Table 9.3 Date Object Methods (continued)
Method
What It Does
setTime()
Sets time from January 1, 1970, in milliseconds
setUTCdate()
Sets the day of the month in universal time
setUTCFullYear()
Sets the year as a four-digit number in universal time
setUTCHours()
Sets the hour in universal time
setUTCMilliseconds()
Sets the millisecond in universal time
setUTCMinutes()
Sets the minute in universal time
setUTCMonth()
Sets the month in universal time
setUTCSeconds()
Sets the second in universal time
setYear()
Sets the number of years since 1900 (00-99)
toGMTString()
Returns the date string in universal format
toLocaleString
Returns the string representing date and time based on locale of
computer as 10/09/99 12:43:22
toSource()
Returns the source of the Date object
toString()
Returns string representing date and time
toUTCString()
Returns string representing date and time as 10/09/99 12:43:22
in universal time
UTC()
Converts comma-delimited values to milliseconds
valueOf()
Returns the equivalence of the Date object in milliseconds
EXAMPLE 9.17
<html>
<head><title>Time and Date</title></head>
<body bgcolor="aqua"><h2>Date and Time</h2>
<big>
<script type="text/javascript">
1
var now = new Date(); // Now is an instance of a Date object
document.write("<b>Local time:</b> " + now + "<br />");
2
var hours=now.getHours();
3
var minutes=now.getMinutes();
4
var seconds=now.getSeconds();
5
var year=now.getFullYear();
Continues
 
Search WWH ::




Custom Search