Skip to content

Instantly share code, notes, and snippets.

@maximishchenko
Created May 6, 2016 09:41
Show Gist options
  • Save maximishchenko/be09a57d4d71c349a3da702307b40528 to your computer and use it in GitHub Desktop.
Save maximishchenko/be09a57d4d71c349a3da702307b40528 to your computer and use it in GitHub Desktop.
JavaScript Difference Between Today and Earlier Date
<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