|
| JAVASCRIPT setUTCSeconds() METHOD
The setUTCSeconds() method in javascript returns the date and time in UTC (Universal Coordinated Time) by setting the seconds. Takes a compulsory second argument as a number from 0 to 59 and an optional milliseconds argument as a number from 0 to 999.
Any optional arguments not supplied will take default values of the current time of user's computer.
The general format is:
dateObject.setUTCSeconds(seconds, milliseconds[optional]);
If you want to return the full date and time with the setUTCSeconds() method, you will first have to create a new date object and then use the new date object with the setUTCSeconds() method.
Example 1: With only the seconds supplied
<script type="text/javascript">
var dd=new Date(); // creates a new date object
dd.setUTCSeconds(48); // sets the date/time
document.write(dd); // outputs the date/time
</script>
The above will output:
Example 2: With all parameters supplied
<script type="text/javascript">
var dd=new Date(); // creates a new date object
dd.setUTCSeconds(37, 500); // sets the date/time
document.write(dd); // outputs the date/time
</script>
The above will output:
See Also:
|
|