Last active
November 25, 2019 09:54
-
-
Save VonSwirl/6011f69143dece7431b5810a777412fc to your computer and use it in GitHub Desktop.
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
/** | |
* Compare 2 dates and to find days remaining. | |
* @param {Date} fromDate This is the starting point date .e.g Date.now() | |
* @param {Date} toDate A date set ini the future you wish to know how many day remain until. | |
* @returns {Number} Days remaining between the 2 dates. | |
* @license MIT https://opensource.org/licenses/MIT | |
* @author Jerome Hurley | |
*/ | |
function daysUntilDate (fromDate, toDate) { | |
const oneDay = 24 * 60 * 60 * 1000 | |
const firstDate = fromDate | |
const secondDate = toDate | |
const dayRemaining = Math.round(Math.abs((firstDate - secondDate) / oneDay)) | |
// DEBUG console.log(dayRemaining) | |
return dayRemaining | |
} | |
export default daysUntilDate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment