HTML / JS中的条件,自动更新日期

时间:2018-05-03 14:54:47

标签: javascript html date automation conditional

我需要在HTML或JS中创建一个条件的自动更新日期。以下是在Excel中创建的示例:

                    Delivery Date       Delivery
Monday, 30.04.18    Saturday, 05.05.18  1
Tuesday, 01.05.18   Saturday, 05.05.18  1
Wednesday, 02.05.18 Saturday, 05.05.18  1
Thursday, 03.05.18  Saturday, 12.05.18  2
Friday, 04.05.18    Saturday, 12.05.18  2
Saturday, 05.05.18  Saturday, 12.05.18  2
Sunday, 06.05.18    Saturday, 12.05.18  2
Monday, 07.05.18    Saturday, 12.05.18  2
Tuesday, 08.05.18   Saturday, 12.05.18  2
Wednesday, 09.05.18 Saturday, 12.05.18  2
Thursday, 10.05.18  Saturday, 19.05.18  3
Friday, 11.05.18    Saturday, 19.05.18  3
Saturday, 12.05.18  Saturday, 19.05.18  3
Sunday, 13.05.18    Saturday, 19.05.18  3
Monday, 14.05.18    Saturday, 19.05.18  3

目标:如果今天和下周六之间的差异小于3,请在此之后使用星期六作为交付日期。如果今天和下周六之间的差异等于/大于3,请使用此星期六作为交货日期。在excel公式中:

=IF((delivery 1 - today) < 3, delivery date 2, delivery 1)

谢谢!

1 个答案:

答案 0 :(得分:0)

比较两个日期(同时检查下一个功能):Compare two dates with JavaScript

添加7天(下周六):https://stackoverflow.com/a/563442/6692092