Fix issue parsing millisecond-precision dates before 1970.

parent 90f73d2c
...@@ -99,7 +99,13 @@ abstract class Model extends BaseModel ...@@ -99,7 +99,13 @@ abstract class Model extends BaseModel
{ {
// Convert UTCDateTime instances. // Convert UTCDateTime instances.
if ($value instanceof UTCDateTime) { if ($value instanceof UTCDateTime) {
return Date::createFromTimestampMs($value->toDateTime()->format('Uv')); $date = $value->toDateTime();
$seconds = $date->format('U');
$milliseconds = abs($date->format('v'));
$timestampMs = sprintf('%d%03d', $seconds, $milliseconds);
return Date::createFromTimestampMs($timestampMs);
} }
return parent::asDateTime($value); return parent::asDateTime($value);
......
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