File tree 2 files changed +31
-1
lines changed
2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
10
10
11
11
For a steady stream of TILs, [ sign up for my newsletter] ( https://crafty-builder-6996.ck.page/e169c61186 ) .
12
12
13
- _ 1309 TILs and counting..._
13
+ _ 1310 TILs and counting..._
14
14
15
15
---
16
16
@@ -432,6 +432,7 @@ _1309 TILs and counting..._
432
432
- [ Generate Random Integers] ( javascript/generate-random-integers.md )
433
433
- [ Get The Location And Size Of An Element] ( javascript/get-the-location-and-size-of-an-element.md )
434
434
- [ Get The Response Status From An Axios Error] ( javascript/get-the-response-status-from-an-axios-error.md )
435
+ - [ Get The Time Components Of A Date] ( javascript/get-the-time-components-of-a-date.md )
435
436
- [ Get The Time Zone Of The Client Computer] ( javascript/get-the-time-zone-of-the-client-computer.md )
436
437
- [ Globally Install A Package With Yarn] ( javascript/globally-install-a-package-with-yarn.md )
437
438
- [ Globally Install Specific Version Of PNPM] ( javascript/globally-install-specific-version-of-pnpm.md )
Original file line number Diff line number Diff line change
1
+ # Get The Time Components Of A Date
2
+
3
+ A ` Date ` object in JavaScript has several functions available to it for getting
4
+ at the time components of that date.
5
+
6
+ ``` javascript
7
+ > const now = new Date ()
8
+ undefined
9
+ > now
10
+ 2023 - 06 - 14T17 : 44 : 06 .425Z
11
+ > now .getMinutes ()
12
+ 44
13
+ > now .getSeconds ()
14
+ 6
15
+ > now .getHours ()
16
+ 12
17
+ ```
18
+
19
+ For a given ` Date ` object, you can access the hours with
20
+ [ ` getHours() ` ] ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getHours ) ,
21
+ the minutes with
22
+ [ ` getMinutes() ` ] ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMinutes ) ,
23
+ and the seconds with
24
+ [ ` getSeconds() ` ] ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getSeconds ) .
25
+
26
+ To round things out, there is also
27
+ [ ` getMilliseconds() ` ] ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMilliseconds )
28
+ and
29
+ [ ` getTimezoneOffset() ` ] ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset ) .
You can’t perform that action at this time.
0 commit comments