136 of 264 menu

setHours method

The setHours method allows you to change the hour value of the date object. It takes hour as first parameter. It can also take minutes, seconds and milliseconds.

Syntax

date.setHours(hours, [minutes], [seconds], [milliseconds]);

Example

Let's set the hours for the current time:

let date = new Date(); date.setDate(12); console.log(date);

Example

Let's set the hours, minutes and seconds for the current point in time:

let date = new Date(); date.setDate(12, 59, 49); console.log(date);

See also

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline