|
-
Oct 17th, 2002, 02:07 PM
#1
Thread Starter
Stuck in the 80s
Last Wednesday's Date?
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:
Code:
if (date('D') == 'Wed') {
echo date('Y-m-d');
} else {
//$last =
echo "Last Wednesday was $last";
}
Any ideas?
-
Oct 17th, 2002, 02:09 PM
#2
Thread Starter
Stuck in the 80s
Would I have to do it like this:
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;
}
}
Or is there an easier way?
-
Oct 17th, 2002, 02:58 PM
#3
Thread Starter
Stuck in the 80s
I suppose using strtotime ("last Wednesday") would be easier
-
Oct 17th, 2002, 03:36 PM
#4
Frenzied Member
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));
-
Oct 17th, 2002, 09:02 PM
#5
Thread Starter
Stuck in the 80s
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.
-
Oct 18th, 2002, 09:27 AM
#6
Frenzied Member
-
Oct 18th, 2002, 10:49 AM
#7
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Oct 18th, 2002, 01:58 PM
#8
Thread Starter
Stuck in the 80s
Originally posted by CornedBee
strtotime rules.
Indeed. I find it more and more useful everyday.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|