-1

I have a problem in PHP: How can I get the next friday of a given day?

E.g. What's the date of next friday following monday 6th April 2015?

Is there a way to pass as a parameter the wanted day to strtotime( "next friday")?


Ok, got it! Thanks to all! The problem with my dates is that they formated like d/m/Y, and I was messing it all up.

        $dt = explode("/", $_SESSION['conj']['dtEnd'][0]);
        $newDate = $dt[2] ."-".$dt[1]."-".$dt[0];
        $nextFriday =  date ('d/m/Y', strtotime("next friday", strtotime($newDate)));
  • 6
    Have you tried? `echo date('Y-m-d', strtotime( "next friday", strtotime('2015-04-06')));` [strtotime()](http://php.net/manual/en/function.strtotime.php) takes an optional second argument – Mark Baker Apr 02 '15 at 13:40
  • May i review your code? Please post what you have tried so far? – Keep Coding Apr 02 '15 at 13:41
  • possible duplicate of [Convert one date format into another in PHP](http://stackoverflow.com/questions/2167916/convert-one-date-format-into-another-in-php) – Bud Damyanov Apr 02 '15 at 13:52
  • 1
    @MarkBaker Since this comment is the only easy and right solution, Could you post it as an answer so the OP can accept the answer? – Loko Apr 02 '15 at 13:59

1 Answers1

2
<?php

$time = strtotime('Monday, April 6, 2015');
$next = strtotime('next friday, 11:59am', $time);
echo  date('l, F j', $next);

?>
Kamran
  • 2,711
  • 2
  • 17
  • 24