Skip to content

Commit

Permalink
Added support for retrieving the current system time with millisecond…
Browse files Browse the repository at this point in the history
…s for `Hyperf\Support\Traits\InteractsWithTime` (#6990)
  • Loading branch information
huangdijia authored Aug 15, 2024
1 parent 6a9d19f commit 2929acc
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Traits/InteractsWithTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,23 @@ protected function parseDateInterval($delay)
* Get the current system time as a UNIX timestamp.
*/
protected function currentTime(): int
{
return $this->currentTimestamp();
}

/**
* Get the current system time as a UNIX timestamp.
*/
protected function currentTimestamp(): int
{
return Carbon::now()->getTimestamp();
}

/**
* Get the current system time as a UNIX timestamp with milliseconds.
*/
protected function currentTimestampMs(): float
{
return Carbon::now()->getPreciseTimestamp(3);
}
}

0 comments on commit 2929acc

Please sign in to comment.