|
| JAVASCRIPT setUTCHours() METHOD
The setUTCHours() method in javascript returns the date and time UTC (Universal Coordinated Time) by setting the hours. Takes a compulsory hour argument as number from 1 to 23, an optional minute argument as a number from 0 to 59, an optional second argument as a number from 0 to 59 and an optional millisecond argument as a number from 0 to 1000.
The general format is:
dateObject.setUTCHours(hour, minutes,[optional] , seconds[optional], milliseconds[optional]);
If you want to return the full date and time with the setUTCHours() method, you will first have to create a new date object and then use the new date object with the setUTCHours() method.
Example 1: With only the hour supplied
<script type="text/javascript">
var dd=new Date(); // creates a new date object
dd.setUTCHours(13); // sets the date
document.write(dd); // outputs the date
</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.setUTCHours(17, 24, 37, 345); // sets the date
document.write(dd); // outputs the date
</script>
The above will output:
See Also:
|
|