<?php
$intervals = array(
'0' => 0,
'86400' => 86400,
'0 second' => 0,
'1 second' => 1,
'1 minute' => 60,
'1 hour' => 60 * 60,
'1 day' => 60 * 60 * 24,
'1 month' => 31 * 60 * 60 * 24
'1 year' => 60 * 60 * 24 * 365,
'10 years' => 60 * 60 * 24 * 365 * 10,
'1 day + 12hours' => 60 * 60 * 24 + 12 * 60 * 60,
);
foreach ($intervals as $interval => $expected) {
if (is_numeric($interval)) {
$found = (int) $interval;
} else {
$zeroDate = new \DateTime();
// can't use @0, it will add 3600 seconds to final output on php 5.3.9 - 5.4.7
$zeroDate->setTimestamp(0);
$zeroDate->add(\DateInterval::createFromDateString($interval));
$found = $zeroDate->getTimestamp();
}
echo sprintf("found %s expected %s\n", $found, $expected);
}
- Output for 5.4.0 - 5.4.28
- Parse error: syntax error, unexpected ''1 year'' (T_CONSTANT_ENCAPSED_STRING), expecting ')' in /in/uaeg6 on line 11
Process exited with code 255. - Output for 5.3.0 - 5.3.28
- Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /in/uaeg6 on line 11
Process exited with code 255.
preferences:
185.85 ms | 949 KiB | 66 Q