<?php
$tests = array("400 seconds", "400.1 seconds", "400.12 seconds", "400.123 seconds");
foreach ($tests as $index => $test) {
var_dump($test);
var_dump(DateInterval::createFromDateString($test)->format("%Hh, %im, %ss"));
var_dump(date_parse($test));
}
- Output for 8.3.0 - 8.3.6
- string(11) "400 seconds"
string(13) "00h, 0m, 400s"
array(13) {
["year"]=>
bool(false)
["month"]=>
bool(false)
["day"]=>
bool(false)
["hour"]=>
bool(false)
["minute"]=>
bool(false)
["second"]=>
bool(false)
["fraction"]=>
bool(false)
["warning_count"]=>
int(0)
["warnings"]=>
array(0) {
}
["error_count"]=>
int(0)
["errors"]=>
array(0) {
}
["is_localtime"]=>
bool(false)
["relative"]=>
array(6) {
["year"]=>
int(0)
["month"]=>
int(0)
["day"]=>
int(0)
["hour"]=>
int(0)
["minute"]=>
int(0)
["second"]=>
int(400)
}
}
string(13) "400.1 seconds"
Fatal error: Uncaught DateMalformedIntervalStringException: Unknown or bad format (400.1 seconds) at position 0 (4): Unexpected character in /in/9S45j:6
Stack trace:
#0 /in/9S45j(6): DateInterval::createFromDateString('400.1 seconds')
#1 {main}
thrown in /in/9S45j on line 6
Process exited with code 255. - Output for 7.3.4 - 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
- string(11) "400 seconds"
string(13) "00h, 0m, 400s"
array(13) {
["year"]=>
bool(false)
["month"]=>
bool(false)
["day"]=>
bool(false)
["hour"]=>
bool(false)
["minute"]=>
bool(false)
["second"]=>
bool(false)
["fraction"]=>
bool(false)
["warning_count"]=>
int(0)
["warnings"]=>
array(0) {
}
["error_count"]=>
int(0)
["errors"]=>
array(0) {
}
["is_localtime"]=>
bool(false)
["relative"]=>
array(6) {
["year"]=>
int(0)
["month"]=>
int(0)
["day"]=>
int(0)
["hour"]=>
int(0)
["minute"]=>
int(0)
["second"]=>
int(400)
}
}
string(13) "400.1 seconds"
Warning: DateInterval::createFromDateString(): Unknown or bad format (400.1 seconds) at position 0 (4): Unexpected character in /in/9S45j on line 6
Fatal error: Uncaught Error: Call to a member function format() on bool in /in/9S45j:6
Stack trace:
#0 {main}
thrown in /in/9S45j on line 6
Process exited with code 255. - Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.36, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.13, 7.3.0 - 7.3.3
- string(11) "400 seconds"
string(13) "00h, 0m, 400s"
array(13) {
["year"]=>
bool(false)
["month"]=>
bool(false)
["day"]=>
bool(false)
["hour"]=>
bool(false)
["minute"]=>
bool(false)
["second"]=>
bool(false)
["fraction"]=>
bool(false)
["warning_count"]=>
int(0)
["warnings"]=>
array(0) {
}
["error_count"]=>
int(0)
["errors"]=>
array(0) {
}
["is_localtime"]=>
bool(false)
["relative"]=>
array(6) {
["year"]=>
int(0)
["month"]=>
int(0)
["day"]=>
int(0)
["hour"]=>
int(0)
["minute"]=>
int(0)
["second"]=>
int(400)
}
}
string(13) "400.1 seconds"
string(11) "00h, 0m, 0s"
array(13) {
["year"]=>
bool(false)
["month"]=>
bool(false)
["day"]=>
bool(false)
["hour"]=>
int(0)
["minute"]=>
int(1)
["second"]=>
int(0)
["fraction"]=>
float(0)
["warning_count"]=>
int(1)
["warnings"]=>
array(1) {
[12]=>
string(29) "Double timezone specification"
}
["error_count"]=>
int(2)
["errors"]=>
array(2) {
[0]=>
string(20) "Unexpected character"
[6]=>
string(47) "The timezone could not be found in the database"
}
["is_localtime"]=>
bool(true)
["zone_type"]=>
int(0)
}
string(14) "400.12 seconds"
string(11) "00h, 0m, 0s"
array(13) {
["year"]=>
bool(false)
["month"]=>
bool(false)
["day"]=>
bool(false)
["hour"]=>
int(0)
["minute"]=>
int(12)
["second"]=>
int(0)
["fraction"]=>
float(0)
["warning_count"]=>
int(1)
["warnings"]=>
array(1) {
[13]=>
string(29) "Double timezone specification"
}
["error_count"]=>
int(2)
["errors"]=>
array(2) {
[0]=>
string(20) "Unexpected character"
[7]=>
string(47) "The timezone could not be found in the database"
}
["is_localtime"]=>
bool(true)
["zone_type"]=>
int(0)
}
string(15) "400.123 seconds"
string(11) "00h, 0m, 3s"
array(13) {
["year"]=>
bool(false)
["month"]=>
bool(false)
["day"]=>
bool(false)
["hour"]=>
int(0)
["minute"]=>
int(12)
["second"]=>
int(0)
["fraction"]=>
float(0)
["warning_count"]=>
int(0)
["warnings"]=>
array(0) {
}
["error_count"]=>
int(1)
["errors"]=>
array(1) {
[0]=>
string(20) "Unexpected character"
}
["is_localtime"]=>
bool(false)
["relative"]=>
array(6) {
["year"]=>
int(0)
["month"]=>
int(0)
["day"]=>
int(0)
["hour"]=>
int(0)
["minute"]=>
int(0)
["second"]=>
int(3)
}
}
- Output for 7.2.17 - 7.2.33
- string(11) "400 seconds"
string(13) "00h, 0m, 400s"
array(13) {
["year"]=>
bool(false)
["month"]=>
bool(false)
["day"]=>
bool(false)
["hour"]=>
bool(false)
["minute"]=>
bool(false)
["second"]=>
bool(false)
["fraction"]=>
bool(false)
["warning_count"]=>
int(0)
["warnings"]=>
array(0) {
}
["error_count"]=>
int(0)
["errors"]=>
array(0) {
}
["is_localtime"]=>
bool(false)
["relative"]=>
array(6) {
["year"]=>
int(0)
["month"]=>
int(0)
["day"]=>
int(0)
["hour"]=>
int(0)
["minute"]=>
int(0)
["second"]=>
int(400)
}
}
string(13) "400.1 seconds"
Warning: DateInterval::createFromDateString(): Unknown or bad format (400.1 seconds) at position 0 (4): Unexpected character in /in/9S45j on line 6
Fatal error: Uncaught Error: Call to a member function format() on boolean in /in/9S45j:6
Stack trace:
#0 {main}
thrown in /in/9S45j on line 6
Process exited with code 255. - Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
- string(11) "400 seconds"
Fatal error: Class 'DateInterval' not found in /in/9S45j on line 6
Process exited with code 255. - Output for 4.4.2 - 4.4.9
- Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/9S45j on line 6
Process exited with code 255. - Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
- Parse error: parse error, unexpected T_OBJECT_OPERATOR in /in/9S45j on line 6
Process exited with code 255. - Output for 4.3.2 - 4.3.4
- Parse error: parse error in /in/9S45j on line 6
Process exited with code 255.
preferences:
296.21 ms | 401 KiB | 388 Q