Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Thanked 5 Times in 5 Posts

    getting dates for previous days within a 7 day period

    Hello all,

    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
    Warm Regards,
    Sir P

  • #2
    God Emperor Fou-Lu's Avatar
    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:
    PHP Code:
    $lastMon strtotime('last Monday'); 
    Returns a timestamp, so you will need to format it using the data function. Hope that helps you!
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts