Commit b76e00c6 authored by Karamel's avatar Karamel
Browse files

Fix reading date string with hour > 12.

parent 8bb51023
......@@ -83,7 +83,7 @@ class DateUtils
public static function readString($string) {
$date = \DateTime::createFromFormat('!Y-m-d', $string);
if ($date === false) {
$date = \DateTime::createFromFormat('Y-m-d h:i', $string);
$date = \DateTime::createFromFormat('Y-m-d H:i', $string);
}
return $date;
}
......
......@@ -105,9 +105,9 @@ class DateUtilsTest extends TestCase {
$this->assertNotEquals(false, $date);
$this->assertEquals('2017-10-01 00:00:00',
$date->format('Y-m-d H:i:s'));
$date = DateUtils::readDate('2017-10-01 11:30');
$date = DateUtils::readDate('2017-10-01 17:30');
$this->assertNotEquals(false, $date);
$this->assertEquals('2017-10-01 11:30:00',
$this->assertEquals('2017-10-01 17:30:00',
$date->format('Y-m-d H:i:s'));
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment