var mydate = new Date ();
Mydate.getyear (); Get Current year (2-bit)
Mydate.getfullyear (); Get full year (4-bit, 1970-????)
Mydate.getmonth (); Get Current month (0-11, 0 for January)
Mydate.getdate (); Get the current day (1-31)
Mydate.getday (); Get Current week x (0-6, 0 for Sunday)
Mydate.gettime (); Gets the current time (number of milliseconds since 1970.1.1)
Mydate.gethours (); Get the current number of hours (0-23)
Mydate.getminutes (); Get the current number of minutes (0-59)
Mydate.getseconds (); Get the current number of seconds (0-59)
Mydate.getmilliseconds (); Get current number of milliseconds (0-999)
Mydate.tolocaledatestring (); Get Current date
var mytime=mydate.tolocaletimestring (); Get current time
Mydate.tolocalestring (); Get Date and time
Typical use
This will display the latest time on the page every other minute, with the format "June 20, 2010 Sunday 12:17:14";
Js
Copy Code code as follows:
<script type= "Text/javascript" >
function ShowTime () {
var time = new Date ();
var temp = time.tolocalestring ();
document.getElementById ("Spantime"). innertext = temp;
SetTimeout (ShowTime, 60000);
}
onload = ShowTime;
</script>
<span id= "Spantime" ></span>
Here to correct the error, thank Sohighthesky Help