Created
August 19, 2018 19:53
-
-
Save smks/d64d28ce35e90474b6e852b697dcbf80 to your computer and use it in GitHub Desktop.
Demonstrates using date-fns to compare days differences
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
import differenceInDays from 'date-fns/difference_in_days' | |
// Last day of tax year: 5th April 2018 | |
const lastDayOfTaxYear = new Date(2018, 4, 5, 0, 0); | |
// My birthday: 18th September 2018 | |
const myBirthday = new Date(2018, 9, 18, 0, 0); | |
const daysDiff = differenceInDays(myBirthday, lastDayOfTaxYear); | |
const content = document.createElement('p'); | |
content.innerHTML = `<p>There are ${daysDiff} days between | |
the last day of tax year and my birthday</p>`; | |
document.body.appendChild(content); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment