Created
February 16, 2023 04:30
-
-
Save Risyandi/6b7273bf3d95bafb54b70bcbc88c995a to your computer and use it in GitHub Desktop.
how to check date
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
function dateDiff(startDate, endDate) { | |
console.log(new Date(startDate), "startDate"); // since user register | |
console.log(new Date(endDate), "endDate"); // date of voucher expired | |
const diffInMs = new Date(endDate) - new Date(startDate); | |
const diffInDays = diffInMs / (1000 * 60 * 60 * 24); | |
console.log(diffInDays, "diffInDays"); | |
if (diffInDays === 5) { | |
console.log("voucher disappear"); | |
} else { | |
console.log("voucher still appear"); | |
} | |
return diffInDays | |
} | |
const startDate = '2023-02-11'; | |
const endDate = '2023-02-16'; | |
dateDiff(startDate, endDate); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment