sethours() can fix the hours part of date function of JavaScript. We can set the hours from 0 to 23. This can only work on date object. Here is the sample code.
var dt= new Date();
document.write(dt + "<br><br>");
The output is here

We can set the hours value to previous value also by using negative value . Just change the this line in above code.
The output is here

We can set the hours value to beyond 23 hours also. Here is one example.
Output is here

We have seen by using sethours we can fix the hours part to any value. This value is independent of present hours value. Try to display the date and time with hours value to display time after two hours from present value ( after reading the present hour ) .
To do this we have to read the present hours part and then add two hours to it. For this new value of hours we have to use sethours function the date object.
Subscribe to our YouTube Channel here


* indicates required
Subscribe to plus2net

    Post your comments , suggestion , error , requirements etc here .

    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 All rights reserved worldwide Privacy Policy Disclaimer