Added support for retrieving the current system time with milliseconds for Hyperf\Support\Traits\InteractsWithTime (#6990)

This commit is contained in:
Deeka Wong 2024-08-15 12:46:42 +08:00 committed by GitHub
parent 8d04672d88
commit 531c173e47
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 0 deletions

View File

@ -2,6 +2,7 @@
## Added ## Added
- [#6990](https://github.com/hyperf/hyperf/pull/6990) Added support for retrieving the current system time with milliseconds for `Hyperf\Support\Traits\InteractsWithTime`.
- [#6998](https://github.com/hyperf/hyperf/pull/6998) Added default methods for `#[AutoController]`. (You can add method `options` which used to support cors middleware) - [#6998](https://github.com/hyperf/hyperf/pull/6998) Added default methods for `#[AutoController]`. (You can add method `options` which used to support cors middleware)
# v3.1.35 - 2024-08-08 # v3.1.35 - 2024-08-08

View File

@ -65,7 +65,23 @@ trait InteractsWithTime
* Get the current system time as a UNIX timestamp. * Get the current system time as a UNIX timestamp.
*/ */
protected function currentTime(): int protected function currentTime(): int
{
return $this->currentTimestamp();
}
/**
* Get the current system time as a UNIX timestamp.
*/
protected function currentTimestamp(): int
{ {
return Carbon::now()->getTimestamp(); return Carbon::now()->getTimestamp();
} }
/**
* Get the current system time as a UNIX timestamp with milliseconds.
*/
protected function currentTimestampMs(): float
{
return Carbon::now()->getPreciseTimestamp(3);
}
} }