0 votes
628 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 603 views
0 votes
1 answer 619 views
0 votes
1 answer 15.6k views
0 votes
1 answer 526 views
asked Jan 26, 2022 in Jquery by Singer
+1 vote
0 answers 1.1k views
0 votes
1 answer 1.4k views
...