<?php
$timestamps = array(
strtotime("now"),
strtotime("-3 seconds"),
strtotime("-30 minutes"),
strtotime("-60 minute"),
strtotime("-90 minutes"),
strtotime("-1550 minutes"),
strtotime("-889385 seconds"),
);
$dateTimeFile = new DateTime();
foreach ($timestamps as $timestamp) {
$dateTimeFile->setTimestamp($timestamp);
$interval = (new DateTime)->diff($dateTimeFile);
echo sprintf(
"%s%s%s%s",
$interval->d > 0 ? $interval->d . "d " : "",
$interval->h > 0 ? $interval->h . "h " : "",
$interval->i > 0 ? $interval->i . "m " : "",
$interval->s > 0 ? $interval->s . "s " : ""
);
echo PHP_EOL;
}
- Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.11, 7.2.14 - 7.2.16, 7.2.18 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
- 3s
30m
1h
1h 30m
1d 1h 50m
10d 7h 3m 5s
- Output for 7.2.17
- 1s
3s
30m
1h
1h 30m
1d 1h 50m
10d 7h 3m 5s
- Output for 7.2.12 - 7.2.13
- 29d 23h 59m 59s
3s
30m
1h
1h 30m
1d 1h 50m
10d 7h 3m 5s
preferences:
223.07 ms | 401 KiB | 329 Q