TimeTrait
trait TimeTrait
Time trait.
Methods
Returns a new instance according to the specified date.
Returns a new instance according to the specified UNIX timestamp.
Returns a new instance according to the specified DOS timestamp.
Returns a new instance according to the specified time string.
Returns the DOS timestamp.
Returns TRUE if the year is a leap year and FALSE if not.
Returns an array containing the number of days in each month of the year.
Returns the number of days in the current or specified month.
Returns a formatted date string according to current locale settings.
Details
at line 30
__construct(string $time = 'now', string|DateTimeZone|null $timeZone = null)
Constructor.
at line 46
static TimeTrait
now(string|DateTimeZone|null $timeZone = null)
Returns a new instance set to the current time.
at line 60
static TimeTrait|false
createFromDate(int $year, int|null $month = null, int|null $day = null, string|DateTimeZone|null $timeZone = null)
Returns a new instance according to the specified date.
at line 78
static TimeTrait|false
createFromTimestamp(int $timestamp, string|DateTimeZone|null $timeZone = null)
Returns a new instance according to the specified UNIX timestamp.
at line 90
static TimeTrait|false
createFromDOSTimestamp(int $timestamp, string|DateTimeZone|null $timeZone = null)
Returns a new instance according to the specified DOS timestamp.
at line 112
static TimeTrait|false
createFromFormat(string $format, string $time, string|DateTimeZone|null $timeZone = null)
Returns a new instance according to the specified time string.
at line 137
$this|TimeTrait|false
setTimezone(string|DateTimeZone $timeZone)
Sets the time zone.
at line 153
$this|TimeTrait|false
forward(int $seconds)
Move forward in time by x seconds.
at line 164
$this|TimeTrait|false
rewind(int $seconds)
Move backward in time by x seconds.
at line 174
int
getDOSTimestamp()
Returns the DOS timestamp.
at line 196
bool
isLeapYear()
Returns TRUE if the year is a leap year and FALSE if not.
at line 213
array
daysInMonths()
Returns an array containing the number of days in each month of the year.
at line 237
int
daysInMonth()
Returns the number of days in the current or specified month.
at line 248
string
formatLocalized(string $format)
Returns a formatted date string according to current locale settings.