Difference between dates in

#1

I’ve two dates d1 and d2, how I could calculate the difference between them given an interval? i.e the steps in minutes, days, hours, days, …

0 Likes

#2

there is dateDiff function for this, it can be used as follows:

> d1 = DateTime.parse('2018-01-01', 'yyyy-MM-dd')
> d2 = DateTime.parse('2018-01-02', 'yyyy-MM-dd')
> DateTime.dateDiff(d1, d2, 'DAY')
1
> DateTime.dateDiff(d1, d2, 'HOUR')
24
> DateTime.dateDiff(d1, d2, 'WEEK')
0
1 Like

How to compare datetime in jasmine test?