I want to be able to find out the date for last Wednesday. If today is Wednesday, then I want to get that date. So far I have:
Any ideas?Code:if (date('D') == 'Wed') {
echo date('Y-m-d');
} else {
//$last =
echo "Last Wednesday was $last";
}
Printable View
I want to be able to find out the date for last Wednesday. If today is Wednesday, then I want to get that date. So far I have:
Any ideas?Code:if (date('D') == 'Wed') {
echo date('Y-m-d');
} else {
//$last =
echo "Last Wednesday was $last";
}
Would I have to do it like this:
Or is there an easier way?Code:if (date('D') == 'Wed') {
echo date('Y-m-d');
} else {
switch (date('D')) {
case 'Thu':
echo date('Y-m-d', strtotime('-1 day'));
break;
}
}
I suppose using strtotime ("last Wednesday") would be easier :eek:
could also do somethign like this: I think this will work
$dy = date("D");
$mn = date("m");
$yr = date("Y")
$lastweek = strftime("%d", mktime(0,0,0,0,$dy-7,0));
D-7 will give me a week ago? What if today's thursday? Right...?
And I think strtotime("Last Wednesday") is about as simple as it gets. :)
hehe good point.
strtotime rules.
Indeed. I find it more and more useful everyday.Quote:
Originally posted by CornedBee
strtotime rules.