Comparing two dates with javascript or datejs (date difference)

后端 未结 3 2244
孤街浪徒
孤街浪徒 2021-02-20 16:36

I am trying to compare two dates which are in Finnish time form like this: dd.mm.YYYY or d.m.YYYY or dd.m.YYYY or d.mm.YYYY.

I am having a hard time finding out how to d

3条回答
  •  盖世英雄少女心
    2021-02-20 17:09

    Using the Date object:

    var today = Date.today();
    var dateToday = Date.parse(today.toString('MMMM d, yyyy'));
    
    var prevMonthDate = dateToday.addDays(-30);
    
    var difference = (dateToday - prevMonthDate)/86400000;
    
    console.log(difference);   //will give you the difference in days. 
    

提交回复
热议问题