0

I got this code from script.php this code for enddate but this code display number days and me im search for displays date end

exmple: code display 30 days expire

and me im search display 18/02/2018 expire

public function days($enddate)
{
    $now = time();
    $your_date = strtotime($enddate);
    $datediff = $your_date - $now;
    $rem = floor($datediff / (60 * 60 * 24));
    return ($rem <= 0 ? 0 : $rem);
}
M.Mino
  • 9
  • 7
  • Can you include a example call to the function and include the actual and expected results? – Dan Jan 18 '18 at 21:41
  • 2
    Possible duplicate of [Adding days to $Date in PHP](https://stackoverflow.com/questions/3727615/adding-days-to-date-in-php) –  Jan 18 '18 at 21:43

1 Answers1

-2

You have to use the date method to format your timestamp as following:

public function days($enddate) {
    $now = time();
    $diff = strtotime($enddate) - $now;
    return date('d/m/Y', $now + $diff);
}
AamirR
  • 11,672
  • 4
  • 59
  • 73
  • Code expires after: 30\/01\/1970 (incorrect) - normally display Code expires after: 18/02/2017 – M.Mino Jan 18 '18 at 21:49