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
    nca
    nca is offline
    New Coder
    Join Date
    Dec 2003
    Posts
    39
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Calculating prevous date

    The correct answer I am looking for is 2014-04-29... yet it comes out with 2014-04-28
    The main goal is to find the same day of week, day of the previous week.
    What am I missing?

    PHP Code:
    $showday '2014-05-05';
    $lastweekdate date('Y-m-d'strtotime('-7 days'strtotime($showday)));
    echo 
    "For the date of $showday<br> Last week on this same day of week would have been $lastweekdate"

  • #2
    Senior Coder
    Join Date
    Aug 2006
    Posts
    1,260
    Thanks
    10
    Thanked 277 Times in 276 Posts
    Both 2014-5-5 and 2014-4-28 are on a Monday. Are you sure you're looking at the right month?

  • #3
    nca
    nca is offline
    New Coder
    Join Date
    Dec 2003
    Posts
    39
    Thanks
    5
    Thanked 0 Times in 0 Posts
    OMG thanks I really was looking at wrong month. So sorry... Admins you can delete this entire thread as I did not see a way to do so


  •  

    Posting Permissions

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