Created
October 2, 2021 22:13
-
-
Save sayyedhammadali/871e2ee88d8d2537382f7c791cc4b3a8 to your computer and use it in GitHub Desktop.
Get the time from a date
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const timeFromDate = date => date.toTimeString().slice(0, 8); | |
console.log(timeFromDate(new Date(2021, 0, 10, 17, 30, 0))); | |
// Result: "17:30:00" | |
console.log(timeFromDate(new Date())); | |
// Result: will log the current time |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment