3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function d2d ($date, $to){ $date = explode ("/", $date); $to = explode ("/", $to); if (count($date) != 3 or count($to) != 3){ return 0; } else { $dateexp = ($date[0] * 100 + $date[1]) * 100 + $date[2]; $toexp = ($to[0] * 100 + $to[1]) * 100 + $to[2]; if ($dateexp > $toexp){ return -1; } elseif ($dateexp == $toexp){ return 0; } else { $dif = 0; $moves = 0; while ($to[0] >= $date[0]){ if ($date[1] != $to[1] or $date[1] == $to[1] and $date[0] != $to[0]){ if ($moves == 0){ if ($date[1] <= 6){ $dif = 31 - $date[2]; $date[1] ++; } elseif ($date[1] > 6 and $date[1] < 12){ $dif = 30 - $date[2]; $date[1] ++; } else { $dif = 29 - $date[2]; $date[1] = 1; $date[0] ++; } } else{ if ($date[1] <= 6){ $dif = $dif + 31; $date[1] ++; } elseif ($date[1] > 6 and $date[1] < 12){ $dif = $dif + 30; $date[1] ++; } else { $dif = $dif + 29; $date[1] = 1; $date[0] ++; } } $moves ++; } else{ if ($moves == 0){ $dif = $to[2] - $date[2]; break; } else{ $dif = $dif + $to[2]; break; } } } } return $dif; } } echo d2d("1396/4/25", "1396/04/25"); ?>
Output for 5.6.30, hhvm-3.15.4 - 3.22.0, 7.0.0 - 7.3.0rc3
0