Last active
August 29, 2015 14:09
-
-
Save sportebois/01969ee08eb8f8923662 to your computer and use it in GitHub Desktop.
Quick days diff
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
var s = document.createElement('script'); | |
s.src = '//cdnjs.cloudflare.com/ajax/libs/moment.js/2.8.3/moment.min.js'; | |
document.body.appendChild(s); | |
s.onload = function() { | |
var testDate = window.prompt('Date à comparer:', 'aaaa-mm-dd'); | |
var result = 'Il y a '+ ~~(moment.duration(moment(testDate).diff()).as('days')) + ' jours entre maintenant et '+ testDate; | |
window.alert(result); | |
}; |
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
<html> | |
<body> | |
Comparaison par jours: <a href="javascript:var s = document.createElement('script'); s.src = '//cdnjs.cloudflare.com/ajax/libs/moment.js/2.8.3/moment.min.js'; document.body.appendChild(s);s.onload = function() {var testDate = window.prompt('Date à comparer:', 'aaaa-mm-dd');var result = 'Il y a '+ ~~(moment.duration(moment(testDate).diff()).as('days')) + ' jours entre maintenant et '+ testDate;window.alert(result);};" | |
>Glisser ce lien jusqu'aux bookrmarks </a> | |
<p>Vous pouvez ensuite fermer cette page, vous n'avez qu'à cliquer le lien lorsque besoin.</p> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment