Skip to content

Latest commit

 

History

History
29 lines (25 loc) · 1.01 KB

get-the-time-components-of-a-date.md

File metadata and controls

29 lines (25 loc) · 1.01 KB

Get The Time Components Of A Date

A Date object in JavaScript has several functions available to it for getting at the time components of that date.

> const now = new Date()
undefined
> now
2023-06-14T17:44:06.425Z
> now.getMinutes()
44
> now.getSeconds()
6
> now.getHours()
12

For a given Date object, you can access the hours with getHours(), the minutes with getMinutes(), and the seconds with getSeconds().

To round things out, there is also getMilliseconds() and getTimezoneOffset().