3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getDaysLeft(DateTimeImmutable $now, DateTimeImmutable $until): void { $diff = $now->diff($until); var_dump( ($diff->invert ? -1 : 1) * ($diff->days + $diff->h / 24 + $diff->i / (24 * 60) + $diff->s / (24 * 60 * 60)) ); var_dump(((int) $diff->format("%r1")) * ($diff->format("%a") + $diff->format("%h") / 24 + $diff->format("%i") / (24 * 60) + $diff->format("%s") / (24 * 60 * 60))); } // subscription has expired half a day ago getDaysLeft(new DateTimeImmutable("2023-11-24 00:00:00"), new DateTimeImmutable("2023-11-23 12:00:00")); // subscription will expire in hald a day getDaysLeft(new DateTimeImmutable("2023-11-24 00:00:00"), new DateTimeImmutable("2023-11-24 12:00:00"));

preferences:
24.99 ms | 404 KiB | 5 Q