Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP date excluding weekend

Tags:

date

php

I am currently doing a website which offers delivery Monday through Friday only.

I am trying to figure out how to add delivery date. For e.g:

"Order today and you can expect delivery on DD/MM/YY"

The above date would require to exclude any weekends

So basically if ordered today the delivery day is 4 working days later excluding weekends.

like image 338
user3636711 Avatar asked May 03 '26 15:05

user3636711


1 Answers

Try this:

<?php
    echo strftime("%e/%m/%y", strtotime("+4 weekday"))
?>

It creates a time string "4 weekdays from now" formatted as DD/MM/YY.

The relative formats for dates that can be used with strtotime are explained here: http://php.net/manual/en/datetime.formats.relative.php

like image 132
JJ. Avatar answered May 05 '26 04:05

JJ.