Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder
    Join Date
    Jun 2008
    Location
    Cornwall
    Posts
    2,099
    Thanks
    297
    Thanked 12 Times in 12 Posts

    Question is it possible to find the date of the last sunday from todays date?

    Hi All

    i am trying to find out how to find out the date of the most recent sunday from the current date.

    for example lets take today its 25/11/2010 but i am trying to find out last sundays date which was 21/11/2010. how would i go about doing this?

    i would want this to work for any future date so tomorrow i want it to work and find the same date 21/11/2010 also if today is a sunday then i want it to return todays date, if that makes sence

    many thanks
    Luke

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Sure, you use strtotime.
    PHP Code:
    $lastSunday strtotime('last sunday');
    print 
    date('Y/m/d'$lastSunday); 
    Same goes for the future or past. Strtotime works on relative dates, using '+/-# day' like +1 day, and minor relatives such as 'today', 'yesterday', and 'tomorrow', 'last X', and 'next X', where X is a day of the week.
    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 ;)

  • Users who have thanked Fou-Lu for this post:

    LJackson (11-25-2010)

  • #3
    Senior Coder
    Join Date
    Jun 2008
    Location
    Cornwall
    Posts
    2,099
    Thanks
    297
    Thanked 12 Times in 12 Posts
    sweet! thanks so much mate,

    Luke


  •  

    Posting Permissions

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