0 votes
121 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 131 views
0 votes
1 answer 171 views
0 votes
1 answer 12.3k views
0 votes
1 answer 86 views
+1 vote
0 answers 809 views
0 votes
1 answer 874 views
...