I know there is similar post about how to get the last Thursday in PHP but I don't want to have the last Thursday compare to the current date but the last Thursday compare to a given date.
For example I have a date dd/mm/yyyy and I want the Thursday before this date. The input is a String ( the format of the string yymmdd) that I want to parse to get the Thursday before this date.
Thanks for your helpAnswer1:
//Assumes it's strtotime parsable, you may need to insert
// slashes with your given format eg (and use 4 digit years)
//It's just that easy ;)
Note that this will always get <em>last</em> thursday, meaning if the given date is a Thursday, it'll report 7 days earlier (but if the date's a Friday it'll only report one day earlier).Answer2:
$day = date('w', $yourTime);
$time = $yourTime - ($day > 4 ? ($day - 4) : ($day + 7 - 4)) * 3600 * 24;
$time are Unix-timestamps.
<strong>Edit:</strong> @Rudu's solution is way more simple, you should stick with that one :)!