Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
January 17, 2006, 4:23 pm
rate this thread
tuesday on thursday or friday every week. How would I do that?
m t W TH F
M T w th f
I would need the dates of the CAPITAL W and T when I run the script
from the last th or f
So if today is 2006-1-19 I would need 2006-1-11 and 2006-1-17
Thanks for the help.
Re: How would I get the dates from the previous wednesday to the last tuesday?
As usually, there's more than one way to do it, here's one:
First find out what was last tuesday, easy as pie with strtotime:
$last_tuesday = strtotime('last tuesday');
After that you can get all the dates with the same method (using
$last_tuesday as a reference point instead of today so we don't get this
weeks "last wednesday" if it happens to be friday, but "last wednesday"
counting from last tuesday).
$last_monday = strtotime('last monday', $last_tuesday);
$last_friday = strtotime('last friday', $last_tuesday);
$last_thursday = strtotime('last thursday', $last_tuesday);
$last_wednesday = strtotime('last wednesday', $last_tuesday);
Now you can convert them to human readable formats using date:
echo date('Y-m-d', $last_monday); // for example
SETI @ Home - Donate your cpu's idle time to science.
Further reading at <http://setiweb.ssl.berkeley.edu/
- » ssh on command line: force using a group size (prime size) of 1024 (and no...
- — The site's Newest Thread. Posted in » Secure Shell Forum