Last active
April 10, 2019 14:19
-
-
Save Banhawy/28089c16ad2c6d9a116a35bf51be2ebd to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function getRemainingTime(endDate){ | |
// Time difference betwwen now and deadline in milliseconds | |
let timeDifference = Date.parse(endDate) - Date.parse(new Date()) | |
let seconds = Math.floor( (timeDifference/1000) % 60 ) | |
let minutes = Math.floor( (timeDifference/1000/60) % 60 ) | |
let hours = Math.floor( (timeDifference *60*60) % 24 ) | |
let days = Math.floor( timeDifference/ (1000*60*60*24) ) | |
return `Countdown ${days} Days, ${hours} Hours, ${minutes} minutes, ${seconds} seconds` | |
} | |
const deadline = "April 13 2019 23:59:59 GMT+0200" | |
console.log(getRemainingTime(deadline)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment