Jump to content

strtotime() for the last saturday of the month


cjb

Recommended Posts

I'm using the strtotime function to define dates like:

$date1 = strtotime("third thursday");

How would I use this function to find the last thursday of the month?

$date1 = strtotime("last thursday"); gives the timestamp for last thursday instead of the last thursday of the month. 

Thanks.  :)
OK I decided to see what I could come up with.

[code]
<?php
$month = date("m") + 1;
$year  = date("Y");
if ($month == 13){
$month = 1;
$year++;
}
echo "<br />Month:  " . $month;
echo "<br />Year:  " . $year;
$ld = strtotime("-1 week thursday", strtotime("1-" . $month . "-" . $year)) + 43200;
echo "<br />" . date ("F j, Y : D",$ld);
?>
[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.