0 votes
1.0k views
in Javascript by
Day.js date difference not working.

Im not sure what I'm doing wrong here?

    var date1 = dayjs(field_data).format('D MMM YYYY');
    var date2 = dayjs().format('D MMM YYYY');
    var diff = date1.diff(date2, 'day');
    alert(diff);

date1 and date2 are alerting properly. But the diff just dont work.

1 Answer

0 votes
by
In my experience, the day difference with format will not work. Its the same with moment.js and Day.js

Try this

    var date1 = dayjs(field_data);
    var date2 = dayjs();
    var diff = date1.diff(date2, 'day');

alert(diff);

Related questions

0 votes
1 answer 929 views
0 votes
1 answer 812 views
0 votes
1 answer 16.7k views
0 votes
1 answer 867 views
asked Jan 26, 2022 in Jquery by Singer
+1 vote
0 answers 1.2k views
0 votes
1 answer 1.6k views
...