Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
01-04-2008, 05:04 PM #1
- Join Date
- Jun 2002
- Thanked 5 Times in 5 Posts
getting dates for previous days within a 7 day period
Have a task that I can't quite get my head around how to put it into code.
I need to work out the date of any day of the week from the last 7 period. So for example today it is Friday the 4th of Jan 2008, I need to know what the date was on the last monday within 7 days (31st dec 2007) or another one... i need to know what the date was last Tuesday (2nd jan 2008) and so forth.
Any one have any resources on this sort of thing?
many thanks all help appreciated
01-04-2008, 05:20 PM #2
- Join Date
- Sep 2002
- Saskatoon, Saskatchewan
- Thanked 2,662 Times in 2,631 Posts
Check out the strtotime() function, could be just what your looking for. For your example, you would literally type in:
Returns a timestamp, so you will need to format it using the data function. Hope that helps you!PHP Code:
$lastMon = strtotime('last Monday');
Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)PHP Code:
header('HTTP/1.1 420 Enhance Your Calm');