The toLocaleTimeString() method returns your current time:
Click the button to display the time as a string.
The method is attached to the instantiated time object: d.toLocaleTimeString()
<script type="text/javascript">
//Locat Date and Time, including GMT difference.  Uses 3 to_string methods.
ourDate = new Date();
document.write("The time and date at your computer's location is: "
+ ourDate.toLocaleString() 
+ ".
");
document.write("The time zone offset between local time and GMT is " 
+ ourDate.getTimezoneOffset() 
+ " minutes.
");
document.write( "The time and date (GMT) is: " 
+ ourDate.toGMTString() 
+ ".
") ;
<:/script>
The getFullYear() method returns the full year of a date:
Return to Table of Contents