0 votes
1.1k 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 988 views
0 votes
1 answer 847 views
0 votes
1 answer 16.9k views
0 votes
1 answer 944 views
asked Jan 26, 2022 in Jquery by Singer
+1 vote
0 answers 1.3k views
0 votes
1 answer 1.7k views
...