Created
May 6, 2016 09:41
-
-
Save maximishchenko/be09a57d4d71c349a3da702307b40528 to your computer and use it in GitHub Desktop.
JavaScript Difference Between Today and Earlier Date
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
<script type="text/javascript"> | |
var date1 = new Date("4/1/2016"); | |
var today = new Date(); | |
var timeDiff = Math.abs(today.getTime() - date1.getTime()); | |
var diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24)); | |
document.write(diffDays); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment