【问题标题】:How to add a year to today's date and default it to the preceding working dayHow to add a year to today\'s date and default it to the preceding working day
【发布时间】:2022-12-02 01:51:23
【问题描述】:

If I want to default a date to the next working day I am using the following:

<?php
    echo(date('d/m/Y',strtotime('+1 Weekdays')));
?>

For example: If a user is adding an item on a Friday it is given a default of the following Monday - the next working day.

I have to create a schedule of events with a start and end date. The end date needs to 1 year in the future on the preceding working day.

For example: If a user adds a schedule that has a start day of Wednesday and the same date in a years time happens to be a Sunday, then the end date needs to default to the previous Friday - the preceding working day.

【问题讨论】:

    标签: php


    【解决方案1】:

    I found the answer:

    <?php
        echo(date(date('d/m/Y',strtotime('+1 year')),strtotime('-1 Weekdays')));
    ?>
    

    【讨论】:

      猜你喜欢
      • 2022-12-28
      • 2023-02-01
      • 2022-12-02
      • 2022-11-09
      • 2022-12-01
      • 2022-12-02
      • 2022-12-19
      • 2022-12-02
      • 1970-01-01
      相关资源
      最近更新 更多