PHP: Create a date/ timestamp with strtotime by setting the time

Everyone knows the strtotime function.
With this one, for example, we can recover the date of 2 weeks ago,

strtotime ('-2 week');

or a year ago

strtotime ('-1 year');

What is interesting is that you can recover the date of 2 weeks ago by defining the time, for example midnight

strtotime ('2 week midnight');

or noon:

strtotime ('-2 week noon');

the full list can be found at the following address here


Leave a Reply