Skip to content

Instantly share code, notes, and snippets.

@AlaeddineMessadi
Last active May 7, 2021 14:14
Show Gist options
  • Save AlaeddineMessadi/b6b69454c9d79556348095f25f0d3592 to your computer and use it in GitHub Desktop.
Save AlaeddineMessadi/b6b69454c9d79556348095f25f0d3592 to your computer and use it in GitHub Desktop.
function parseTime
function parseTime(
time: number
): { hours: number; minutes: number; seconds: number; milliseconds: number } {
const date = new Date(time);
const hours = date.getHours() + date.getTimezoneOffset() / 60 - 24;
const minutes = date.getMinutes();
const seconds = date.getSeconds();
const milliseconds = date.getMilliseconds();
return {
hours,
minutes,
seconds,
milliseconds
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment