Skip to content

Commit

Permalink
Update date.php
Browse files Browse the repository at this point in the history
  • Loading branch information
andrepereiradasilva committed Sep 2, 2016
1 parent 21b3ce3 commit e3a0667
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions libraries/joomla/date/date.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 $second 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.
Expand Down Expand Up @@ -105,6 +106,14 @@ 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.
if ($date === 'now')
{
$now = microtime(true);
$micro = sprintf("%06d", ($now - floor($now)) * 1000000);
$date = date('Y-m-d H:i:s.' . $micro, $now);
}

// Call the DateTime constructor.
parent::__construct($date, $tz);

Expand Down

0 comments on commit e3a0667

Please sign in to comment.