I’m retrieving an entry from a database with a date associated with it.
I want to be able to get the previous Sunday and the next Saturday relative to that specific date to populate a jQuery datepicker.
I know how to do it with the actual time/date with :
strtotime('last Sunday')
but I don’t know how to do that for a date other than now…
Thanks.
Use the second argument of
strtotimeto specify the date to calculate "last Sunday" and other relative dates from:https://www.php.net/strtotime
Example:
Output: