Skip to main content

Zymba Documentation

Date

Text
object @Date() {
FORMAT_ISO8601;
FORMAT_ISO9075;
FORMAT_RFC1036;
FORMAT_RFC1123;
FORMAT_RFC2822;
FORMAT_RFC3339;
FORMAT_RFC822;
FORMAT_RFC850;
JUDGMENTDAY;
create(?int $day, ?int $month, ?int $year, int $hour, int $minute, int $second): int {}
createUTC(?int $day, ?int $month, ?int $year, int $hour, int $minute, int $second): int {}
format(string $format, ?int $timestamp): string {}
formatUTC(string $format, ?int $timestamp): string {}
getDay(?int $timestamp): int {}
getDayOfWeek(?int $timestamp): int {}
getDayOfWeekISO8601(?int $timestamp): int {}
getDayOfYear(?int $timestamp): int {}
getDaysInMonth(?int $timestamp): int {}
getHour(?int $timestamp): int {}
getMinute(?int $timestamp): int {}
getMonth(?int $timestamp): int {}
getSecond(?int $timestamp): int {}
getTimezone(): string {}
getTimezoneAbbreviation(): string {}
getTimezoneOffset(): int {}
getWeekISO8601(?int $timestamp): int {}
getYear(?int $timestamp): int {}
getYearISO8601(?int $timestamp): int {}
inDST(?int $timestamp): bool {}
isLeapYear(?int $timestamp): bool {}
isMidnight(?int $timestamp): bool {}
isValid(?int $day, ?int $month, ?int $year): bool {}
listTimezones(): object {}
now(): int {}
nowExact(): float {}
parse(string $string): int {}
today(): int {}
truncateDay(?int $timestamp): int {}
truncateMonth(?int $timestamp): int {}
truncateYear(?int $timestamp): int {}
}

Static date and time related constants and functions.

Functions

Creates the timestamp of a Gregorian date formed by its components.

CODE
@Date.create(?int $day, ?int $month, ?int $year, int $hour, int $minute, int $second): int
Parameters
NameTypeValueDefault
day?intnow
month?intnow
year?intnow
hourint0
minuteint0
secondint0
Returns
TypeValue
int

Creates the timestamp of a Gregorian date formed by its components using UTC instead of local time.

CODE
@Date.createUTC(?int $day, ?int $month, ?int $year, int $hour, int $minute, int $second): int
Parameters
NameTypeValueDefault
day?intnow
month?intnow
year?intnow
hourint0
minuteint0
secondint0
Returns
TypeValue
int

Returns the formatted representation of a date according to a specific PHP-compatible format.

CODE
@Date.format(string $format, ?int $timestamp): string
Parameters
NameTypeValueDefault
formatstring"c"
timestamp?intnow
Returns
TypeValue
string

Returns the formatted representation of a date according to a specific PHP-compatible format using UTC instead of local time.

CODE
@Date.formatUTC(string $format, ?int $timestamp): string
Parameters
NameTypeValueDefault
formatstring"c"
timestamp?intnow
Returns
TypeValue
string

Gets the day of the month (1-31) of a date.

CODE
@Date.getDay(?int $timestamp): int
Parameters
NameTypeValueDefault
timestamp?intnow
Returns
TypeValue
int

Gets the day of the week (0-6) of a date.

CODE
@Date.getDayOfWeek(?int $timestamp): int
Parameters
NameTypeValueDefault
timestamp?intnow
Returns
TypeValue
int

Gets the day of the week (1-7) of a date according to $0.

CODE
@Date.getDayOfWeekISO8601(?int $timestamp): int
Parameters
NameTypeValueDefault
timestamp?intnow
Returns
TypeValue
int

Gets the day of the year (0-365) of a date.

CODE
@Date.getDayOfYear(?int $timestamp): int
Parameters
NameTypeValueDefault
timestamp?intnow
Returns
TypeValue
int

Gets the number of days in the month (28-31) of a date.

CODE
@Date.getDaysInMonth(?int $timestamp): int
Parameters
NameTypeValueDefault
timestamp?intnow
Returns
TypeValue
int

Gets the hour (0-23) of a date.

CODE
@Date.getHour(?int $timestamp): int
Parameters
NameTypeValueDefault
timestamp?intnow
Returns
TypeValue
int

Gets the minute (0-59) of a date.

CODE
@Date.getMinute(?int $timestamp): int
Parameters
NameTypeValueDefault
timestamp?intnow
Returns
TypeValue
int

Gets the month (1-12) of a date.

CODE
@Date.getMonth(?int $timestamp): int
Parameters
NameTypeValueDefault
timestamp?intnow
Returns
TypeValue
int

Gets the second (0-59) of a date.

CODE
@Date.getSecond(?int $timestamp): int
Parameters
NameTypeValueDefault
timestamp?intnow
Returns
TypeValue
int

Gets the current time zone name as defined by the IANA Time Zone Database.

CODE
@Date.getTimezone(): string
Returns
TypeValue
string

Gets the current time zone abbreviation.

CODE
@Date.getTimezoneAbbreviation(): string
Returns
TypeValue
string

Gets the current time zone offset in number of seconds from UTC.

CODE
@Date.getTimezoneOffset(): int
Returns
TypeValue
int

Gets the week number in the year of a date according to $0.

CODE
@Date.getWeekISO8601(?int $timestamp): int
Parameters
NameTypeValueDefault
timestamp?intnow
Returns
TypeValue
int

Gets the 4-digit year of a date.

CODE
@Date.getYear(?int $timestamp): int
Parameters
NameTypeValueDefault
timestamp?intnow
Returns
TypeValue
int

Gets the 4-digit year of a date according to $0.

CODE
@Date.getYearISO8601(?int $timestamp): int
Parameters
NameTypeValueDefault
timestamp?intnow
Returns
TypeValue
int

Determines whether a date is in daylight saving time.

CODE
@Date.inDST(?int $timestamp): bool
Parameters
NameTypeValueDefault
timestamp?intnow
Returns
TypeValue
bool

Determines whether the year of a date is a leap year.

CODE
@Date.isLeapYear(?int $timestamp): bool
Parameters
NameTypeValueDefault
timestamp?intnow
Returns
TypeValue
bool

Determines whether a date is midnight of the day.

CODE
@Date.isMidnight(?int $timestamp): bool
Parameters
NameTypeValueDefault
timestamp?intnow
Returns
TypeValue
bool

Determines whether a Gregorian date formed by specific components is valid.

CODE
@Date.isValid(?int $day, ?int $month, ?int $year): bool
Parameters
NameTypeValueDefault
day?intnow
month?intnow
year?intnow
Returns
TypeValue
bool

List all available time zones.

CODE
@Date.listTimezones(): object
Returns
TypeValue
object[timezone, ...]

Returns the timestamp for the current date and time.

CODE
@Date.now(): int
Returns
TypeValue
int

Returns the exact timestamp for the current date and time including microseconds in the fractional part.

CODE
@Date.nowExact(): float
Returns
TypeValue
float

Parses a textual representation of date and time and returns the corresponding timestamp.

CODE
@Date.parse(string $string): int
Parameters
NameTypeValueDefault
stringstring""
Returns
TypeValue
int
null

Returns the timestamp for today at midnight.

CODE
@Date.today(): int
Returns
TypeValue
int

Truncates a date to midnight of the day.

CODE
@Date.truncateDay(?int $timestamp): int
Parameters
NameTypeValueDefault
timestamp?intnow
Returns
TypeValue
int

Truncates a date to the first day of the month.

CODE
@Date.truncateMonth(?int $timestamp): int
Parameters
NameTypeValueDefault
timestamp?intnow
Returns
TypeValue
int

Truncates a date to the first day of the year.

CODE
@Date.truncateYear(?int $timestamp): int
Parameters
NameTypeValueDefault
timestamp?intnow
Returns
TypeValue
int