diff --git a/libraries/joomla/date/date.php b/libraries/joomla/date/date.php index f26f266bd5f95..5f48bc854c379 100644 --- a/libraries/joomla/date/date.php +++ b/libraries/joomla/date/date.php @@ -24,6 +24,7 @@ * @property-read string $hour H - 24-hour format of an hour with leading zeros. * @property-read string $minute i - Minutes with leading zeros. * @property-read string $second s - Seconds with leading zeros. + * @property-read string $microsecond u - Microseconds with leading zeros. * @property-read string $month m - Numeric representation of a month, with leading zeros. * @property-read string $ordinal S - English ordinal suffix for the day of the month, 2 characters. * @property-read string $week W - Numeric representation of the day of the week. @@ -105,6 +106,9 @@ public function __construct($date = 'now', $tz = null) date_default_timezone_set('UTC'); $date = is_numeric($date) ? date('c', $date) : $date; + // If now, add the microseconds to date. + $date = $date === 'now' ? parent::createFromFormat('U.u', number_format(microtime(true), 6, '.', ''), $tz)->format('Y-m-d H:i:s.u') : $date; + // Call the DateTime constructor. parent::__construct($date, $tz);