Last active
September 10, 2020 08:07
-
-
Save robozavri/2414756173cfa846bfc4bae1a2eb08da to your computer and use it in GitHub Desktop.
#javascript get difference beetwen two dates and set timeout moment.js
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
var a = moment();//now | |
var b = moment('2020-04-30T13:28:00'); | |
console.log('now',moment().toDate()); | |
console.log(a.diff(b, 'milisecunds')) // 44700 | |
console.log(a.diff(b, 'seconds')) // 44700 | |
console.log(a.diff(b, 'minutes')) // 44700 | |
console.log(a.diff(b, 'hours')) // 745 | |
console.log(a.diff(b, 'days')) // 31 | |
console.log(a.diff(b, 'weeks')) // 4 | |
setTimeout(()=>{ //<<<--- using ()=> syntax | |
console.log('wow works now is :',moment().toDate()) // 4 | |
},Math.abs((a.diff(b, 'milisecunds') ) ) ); | |
console.log( Math.abs((a.diff(b, 'milisecunds') ) ) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment