Date form PHP



  • The challenge is to remove the date of the next day after 12:00 and not take into account Sunday with php

    For example:

    now 2021-11-04 11:00 - has to be displayed 2021-11-04 now 2021-11-04 12:30 - has to display 2021-11-05

    Sunday:

    now 2021-11-06 12:30 (Sobbot) - has to be displayed 2021-11-08 (Monday)

    Doing so shows the date of the next day, but this is how to add a 12:00 count and delete on a Sunday without knowing how to do it.

    $data['date_shipment'] = date("Y-m-d", strtotime("+1 day"));
    


  • // текущее ыремя
    $date = time();
    // после полудня - прибавляем день
    if (date('H:m', $date) > '12:00') {
        $date = strtotime("+1 day", $date);
    }
    // вс - прибавляем день
    if(! date('w', $date)) {
            $date = strtotime("+1 day", $date);
    }
    
    print(date('r', $date));
    


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2