Copyright ©

Javascript Date setHours() Method

previous next



Javascript date setHours() method sets the hours for a specified date according to local time.


Date.setHours(hoursValue[, minutesValue[, 
                                  secondsValue[, msValue]]])

Note: Paramters in the bracket are always optional

Here is the detail of parameters:

If you do not specify the minutesValue, secondsValue, and msValue parameters, the values returned from the getUTCMinutes, getUTCSeconds, and getMilliseconds methods are used.

Return Value:



<title>JavaScript setHours Method</title>
<script type="text/javascript">
   var dt = new Date( "Aug 28, 2008 23:30:00" );
   dt.setHours( 02 );
   document.write( dt ); 

This will produce following result :

Thu Aug 28 02:30:00 UTC+0530 2008 

To understand it in better way you can Try it yourself.

previous next

Copyright ©