Skip to content

Instantly share code, notes, and snippets.

@troy0820
Last active June 16, 2020 00:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save troy0820/36a2d2da5adfb899d1e4af612530ef72 to your computer and use it in GitHub Desktop.
Save troy0820/36a2d2da5adfb899d1e4af612530ef72 to your computer and use it in GitHub Desktop.
const announcementTime = new Date()
const tooEarly = new Date("2020-02-24T04:30:00.001Z")
console.log(formatTime(announcementTime, tooEarly))
function formatTime(announcementTime, tooEarly) {
const formattedTime = new Date(tooEarly.getTime() + announcementTime.getTimezoneOffset() * 60 * 1000)
return `At ${announcementTime} Steve said that ${formattedTime.getHours()}:${formattedTime.getMinutes()} is to early`;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment