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 28
__construct(string $time = 'now', DateTimeZone|string|null $timeZone = null)
Constructor.
at line 44
static TimeTrait
now(DateTimeZone|string|null $timeZone = null)
Returns a new instance set to the current time.
at line 58
static false|TimeTrait
createFromDate(int $year, int|null $month = null, int|null $day = null, DateTimeZone|string|null $timeZone = null)
Returns a new instance according to the specified date.
at line 76
static false|TimeTrait
createFromTimestamp(int $timestamp, DateTimeZone|string|null $timeZone = null)
Returns a new instance according to the specified UNIX timestamp.
at line 88
static false|TimeTrait
createFromDOSTimestamp(int $timestamp, DateTimeZone|string|null $timeZone = null)
Returns a new instance according to the specified DOS timestamp.
at line 110
static false|TimeTrait
createFromFormat(string $format, string $time, DateTimeZone|string|null $timeZone = null)
Returns a new instance according to the specified time string.
at line 135
$this|false|TimeTrait
setTimezone(DateTimeZone|string $timeZone)
Sets the time zone.
at line 151
$this|false|TimeTrait
forward(int $seconds)
Move forward in time by x seconds.
at line 162
$this|false|TimeTrait
rewind(int $seconds)
Move backward in time by x seconds.
at line 172
int
getDOSTimestamp()
Returns the DOS timestamp.
at line 194
bool
isLeapYear()
Returns TRUE if the year is a leap year and FALSE if not.
at line 211
array
daysInMonths()
Returns an array containing the number of days in each month of the year.
at line 235
int
daysInMonth()
Returns the number of days in the current or specified month.
at line 246
string
formatLocalized(string $format)
Returns a formatted date string according to current locale settings.