Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Current implementations:
- Simple method (Date, All Timezones)
- JavaScript
- Various methods (Date)
- Simple methods (Time)
- Kotlin
- Various methods (Date & Time)
- Ocaml
Expand Down
16 changes: 16 additions & 0 deletions js/time.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// getting the time in UTC format in JavaScript

// get the current datetime based on the user's computer's local timezone
const now = new Date();

// get the hours in the UTC standard (Coordinated Universal Time)
const hours = now.getUTCHours();

// get the minutes in the UTC standard (Coordinated Universal Time)
const minutes = now.getUTCMinutes();

// get the seconds in the UTC standard (Coordinated Universal Time)
const seconds = now.getUTCSeconds();

// display the time
console.log(`point of time, the variable was created: ${hours}:${minutes}:${seconds}`);