|
| JAVASCRIPT getUTCSeconds() METHOD
The getUTCSeconds() method in javascript returns the seconds of time in UTC (Universal Coordinated Time) as numbers from 0 to 59.
The general format is:
dateObject.getUTCSeconds();
If you want to return the seconds with getUTCSeconds() method, you will first have to create a new date object and then use the new date object with the getUTCSeconds() method.
Example 1: Using getUTCSeconds() for the seconds of the current time
<script type="text/javascript">
var ss=new Date(); // creates new date object
ss=ss.getUTCSeconds(); // returns the seconds
document.write(ss); // outputs the seconds
</script>
The above will output:
Example 2: Using getUTCSeconds() to get the seconds of a specified date/time:
<script type="text/javascript">
var ss=new Date("January 16, 2008 21:37:23"); // creates a new date object
ss=ss.getUTCSeconds(); // returns the seconds
document.write(ss); // outputs the seconds
</script>
The above will output:
See Also:
|
|