3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function pluralize( $count, $text ) { return $count . ( ( $count == 1 ) ? ( " $text" ) : ( " ${text}s" ) ); } $date = new \DateTime('2015-05-24 00:00:00'); $time = new \DateTime('0000-00-00 21:22:00'); $pickUpDateTime = new \DateTime(); $pickUpDateTime->setDate($date->format('Y'), $date->format('m'), $date->format('d')); $pickUpDateTime->setTime($time->format('H'), $time->format('i'), $time->format('s')); $now = new DateTime("now"); $interval = date_diff($now, $pickUpDateTime); if ( $v = $interval->d >= 1 ) echo pluralize( $interval->d, 'day' ) ;
based on eQ5vE
Output for 5.3.21 - 5.4.45, 5.6.28, 7.0.20 - 7.2.0
10 days
Output for 5.5.28, 5.5.31, 7.0.6
27 days
Output for 7.0.5
9 days
Output for 5.5.34, 7.0.4
17 days
Output for 7.0.3
25 days
Output for 5.5.35, 7.0.2
29 days
Output for 5.5.24, 5.6.11, 7.0.1
30 days
Output for 7.0.0
2 days
Output for 5.6.21
8 days
Output for 5.6.20
16 days
Output for 5.6.19
14 days
Output for 5.6.13, 5.6.18
21 days
Output for 5.6.12, 5.6.17
26 days
Output for 5.6.9, 5.6.16
3 days
Output for 5.5.25, 5.6.15
4 days
Output for 5.6.14
20 days
Output for 5.6.10
Output for 5.6.8
5 days
Output for 5.5.33
15 days
Output for 5.5.29, 5.5.32
23 days
Output for 5.5.30
7 days
Output for 5.5.27
28 days
Output for 5.5.26
1 day