Returns an integer representing the system time in microseconds (1/1000000 second intervals) since Jan 1, 1970 00:00:00Z.
int clock_getmicros() (CONST)
$time = clock_getmicros();
Table 3.39. Arguments and Return Values for clock_getmicros()
|
Argument Type |
Return Type |
Description |
|---|---|---|
|
n/a |
Returns the number of microseconds (1/1000000 second) since Jan 1, 1970 00:00. |
This function does not throw any exceptions.
Returns an integer representing the system time in milliseconds (1/1000 second intervals since Jan 1, 1970 00:00).
int clock_getmillis() (CONST)
$time = clock_getmillis();
Table 3.40. Arguments and Return Values for clock_getmillis()
|
Argument Type |
Return Type |
Description |
|---|---|---|
|
n/a |
Returns the number of milliseconds (1/1000 second) since Jan 1, 1970 00:00. |
This function does not throw any exceptions.
Returns the system time in nanoseconds (1/1000000000 second intervals) since Jan 1, 1970 00:00:00Z.
int clock_getnanos() (CONST)
$time = clock_getnanos();
Table 3.41. Arguments and Return Values for clock_getnanos()
|
Argument Type |
Return Type |
Description |
|---|---|---|
|
n/a |
Returns the number of nanoseconds (1/1000000000 second) since Jan 1, 1970 00:00:00Z. |
This function does not throw any exceptions.
Table 3.42. Arguments and Return Values for date_info()
Argument Type | Return Type | Description |
|---|---|---|
| Returns a hash of broken-down date/time information for the given date argument; if the variant with no argument is used, then the current date/time is assumed. |
This function does not throw any exceptions.
Table 3.43. Date Info Hash Description
Key | Type | Absolute/Relative | Description |
|---|---|---|---|
| Both | True if the date is a relative date, False if it is absolute | |
| Both | The year value of the date | |
| Both | The month value of the date | |
| Both | The day value of the date (day of the month for absolute dates) | |
| Both | The hour value of the date | |
| Both | The minute value of the date | |
| Both | The second value of the date | |
| Both | The microsecond value of the date | |
| Absolute Only | The day of the week, where 0=Sunday, 1=Monday, ... 6=Saturday | |
| Absolute Only | The ordinal day number in the year. | |
| Absolute Only | Offset from UTC in seconds east; if the time zone is west of UTC then the value will be negative. | |
| Absolute Only | A flag if daylight savings time is in effect | |
| Absolute Only | The time zone for the time. | |
| Absolute Only | The name of the time zone for the given time (ex: "CEST" for Central European Summer Time for a time during summer time or "CET" for Central European Time for the same time zone while daylight savings time is not active). |
Converts an integer argument representing the offset in milliseconds from January 1, 1970 in the local time zone to a date in the local time zone.
See also date(), date_us(), and localtime().
my date $date = date_ms(1); # returns 1970-01-01T00:00:00.001
This function does not throw any exceptions.
Converts an integer argument representing the offset in microseconds from January 1, 1970 in the local time zone to a date in the local time zone.
See also date(), date_ms(), and localtime().
my date $date = date_us(1); # returns 1970-01-01T00:00:00.000001
This function does not throw any exceptions.
Table 3.46. Arguments and Return Values for days()
|
Argument Type |
Return Type |
Description |
|---|---|---|
|
Returns a relative date/time value corresponding to the number of days passed as an argument, to be used in date arithmetic. |
This function does not throw any exceptions.
Returns a formatting string for a date argument passed. See Date Formatting for information about the formatting string.
string format_date(string, date) (CONST)
my string $str = format_date("Day, Mon D, YYYY-MM-DD HH:mm:SS", 2004-02-01T12:30:00);
# returns "Sunday, Feb 1, 2004-02-01 12:30:00"
Table 3.47. Arguments and Return Values for format_date()
Argument Type | Return Type | Description |
|---|---|---|
| Formats the date value using the string as a formatting specification. |
This function does not throw any exceptions.
Table 3.48. Date Format Arguments
Format Code | Description |
|---|---|
| last two digits of year |
| four-digit year |
| non zero-padded month number (1-12) |
| zero-padded two-digit month number (01-12) |
| long month string (ex: January) |
| long month string capitalized (ex: JANUARY) |
| abbreviated month (ex: Jan) |
| abbreviated month, capitalized (ex: JAN) |
| non zero-padded day number (1 - 31) |
| zero-padded day number (01 - 31) |
| long day of week string (ex: Monday) |
| long day of week string, capitalized (ex: MONDAY) |
| abbreviated day of week string (ex: Mon) |
| abbreviated day of week string capitalised (ex: MON) |
| non zero-padded hour number (0 - 23) |
| zero-padded hour number (00 - 23) |
| non zero-padded hour number, 12-hour clock (1 - 12) |
| zero-padded hour number, 12-hour clock (01 - 12) |
| non zero-padded minute number (0 - 59) |
| zero-padded minute number (00 - 59) |
| non zero-padded second number (0 - 59) |
| zero-padded second number (00 - 59) |
| AM or PM (upper-case) |
| am or pm (lower-case) |
| non zero-padded millisecond number (0 - 999) |
| zero-padded millisecond number (000 - 999) |
| non zero-padded microsecond number (0 - 999999) |
| zero-padded microsecond number (000000 - 999999) |
| microseconds, with trailing zeros removed (suitable for use after the '.') |
| local time zone name (ex: 'EST') if available, otherwise the UTC offset (see 'Z') |
| time zone UTC offset like +HH:mm[:SS], seconds are included if non-zero |
All other text is output directly in the output text unchanged.
Returns an integer value representing the the number of microseconds in the value of the date passed (can be either a relative or absolute date).
If the argument is an absolute date/time value, then the resulting number is calculated from the present time. Fixed-time arguments in the past will result in a return value of 0; this function can only return a negative value if passed a relative date/time value.
my int $us = get_duration_microseconds(PT2M15S3u); # returns 135000003
Table 3.50. Arguments and Return Values for get_duration_microseconds()
|
Argument Type |
Return Type |
Description |
|---|---|---|
|
Returns an integer value representing the the number of microseconds in the value of the date passed; note that the return value will be calculated from the present time if an absolute date/time value argument is passed, but in this case will never be negative; fixed-time arguments in the past will result in a value of 0 being returned. |
Returns an integer value representing the the number of milliseconds in the value of the date passed (can be either a relative or absolute date).
If the argument is an absolute date/time value, then the resulting number is calculated from the present time. Fixed-time arguments in the past will result in a return value of 0; this function can only return a negative value if passed a relative date/time value.
my int $us = get_duration_milliseconds(PT2M15S3u); # returns 135000
Table 3.51. Arguments and Return Values for get_duration_milliseconds()
|
Argument Type |
Return Type |
Description |
|---|---|---|
|
Returns an integer value representing the the number of milliseconds in the value of the date passed; note that the return value will be calculated from the present time if an absolute date/time value argument is passed, but in this case will never be negative; fixed-time arguments in the past will result in a value of 0 being returned. |
Returns an integer value representing the the number of seconds in the value of the date passed (can be either a relative or absolute date).
If the argument is an absolute date/time value, then the resulting number is calculated from the present time. Fixed-time arguments in the past will result in a return value of 0; this function can only return a negative value if passed a relative date/time value.
my int $us = get_duration_seconds(PT2M15S3u); # returns 135
Table 3.52. Arguments and Return Values for get_duration_seconds()
|
Argument Type |
Return Type |
Description |
|---|---|---|
|
Returns an integer value representing the the number of seconds in the value of the date passed; note that the return value will be calculated from the present time if an absolute date/time value argument is passed, but in this case will never be negative; fixed-time arguments in the past will result in a value of 0 being returned. |
Returns the number of seconds of the date and time in local time passed since Jan 1, 1970, 00:00:00 Z (UTC). Negative values are returned for dates before the epoch.
This function is equivalent to mktime().
$secs = get_epoch_seconds(2007-09-23T00:00:01);
This function does not throw any exceptions.
Returns a date/time value representing midnight on the date passed (strips the time from the date passed and returns the new value)
$date = get_midnight(2007-01-23T11:24:03.250); # returns 2007-01-23T00:00:00.000
Returns an integer value representing the months value of the date passed (can be either a relative or absolute date).
int get_months(date) (CONST)
nothing get_months() (RT_NOOP)
$months = get_months(2007-01-23); # returns 1
Retuns an absolute date value for the ISO-8601 calendar week information passed (year, week number, optional: weekday, where 1=Monday, 7=Sunday) in the current time zone. If the weekday is omitted, Monday (1) is assumed; throws an exception if the arguments are invalid.
date getDateFromISOWeek(softint $year, softint $month, softint $wday = 1)
$date = getDateFromISOWeek(2007, 3); # returns 2007-01-15T00:00:00
Table 3.62. Arguments and Return Values for getDateFromISOWeek()
|
Argument Type |
Return Type |
Description |
|---|---|---|
|
Retuns an absolute date value in the local time zone for the ISO-8601 calendar week information passed (year, week number, optional: week day). If the week day is passed, it must be in the range 1 (Monday) - 7 (Sunday) inclusive. |
Table 3.63. Exceptions Thrown by getDateFromISOWeek()
err | desc |
|---|---|
| The week number is not valid for the given year. |
| The day number is not between 1 (Monday) and 7 (Sunday) inclusive. |
Returns an integer representing the day of the week for the absolute date passed (0=Sunday, 6=Saturday)
int getDayOfWeek(date) (CONST)
$dow = getDayOfWeek(2007-05-15); # returns 2
Table 3.64. Arguments and Return Values for getDayOfWeek()
|
Argument Type |
Return Type |
Description |
|---|---|---|
|
Returns an integer representing the day of the week for the absolute date passed (0=Sunday, 6=Saturday) |
Returns an integer representing the ordinal day number in the year for the absolute date passed
int getDayNumber(date) (CONST)
$dn = getDayNumber(2007-05-15); # returns 135
Table 3.65. Arguments and Return Values for getDayNumber()
|
Argument Type |
Return Type |
Description |
|---|---|---|
|
Returns an integer representing the ordinal day number in the year for the absolute date passed |
Returns an integer representing the ISO-8601 day of the week for the absolute date passed (1=Monday, 7=Sunday)
$dow = getISODayOfWeek(2007-05-15); # returns 2 for Tuesday
Table 3.66. Arguments and Return Values for getISODayOfWeek()
|
Argument Type |
Return Type |
Description |
|---|---|---|
|
Returns an integer representing the ISO-8601 day of the week for the absolute date passed (1=Monday, 7=Sunday) |
Returns a hash representing the ISO-8601 calendar week information for the absolute date passed (hash keys: year, week, day). Note that the ISO-8601 year does not always correspond with the calendar year at the end and the begin ning of every year (for example 2006-01-01 is ISO-8601 calendar week format is: year=2005, week=52, day=7)
$h = getISOWeekHash(2007-05-15); # returns year=2007, week=20, day=2
Table 3.67. Arguments and Return Values for getISOWeekHash()
|
Argument Type |
Return Type |
Description |
|---|---|---|
|
Returns a |
Returns a string representing the ISO-8601 calendar week information for the absolute date passed (ex: 2006-01-01 = "2005-W52-7"). Note that the ISO-8601 year does not always correspond with the calendar year at the end and the beginning of every year (for example 2006-01-01 is ISO-8601 calendar week format is: year=2005, week=52, day=7)
$str = getISOWeekString(2007-05-15); # returns "2007-W20-2"
Table 3.68. Arguments and Return Values for getISOWeekString()
|
Argument Type |
Return Type |
Description |
|---|---|---|
|
Returns a string representing the ISO-8601 calendar week information for the absolute date passed (ex: 2006-01-01 = "2005-W52-7") |
Returns the date and time in GMT; if no argument is passed, then the current UTC time with a resolution of a second is returned. Otherwise the single argument must be an integer giving the number of seconds since Jan 1, 1970, 00:00:00, or an absolute date/time value that will be returned as the sme time in UTC (GMT).
See also now_utc().
date gmtime(date $date) (CONST)
date gmtime(softint $epoch_seconds, softint $microseconds = 0) (CONST)
$date = gmtime(now_us()); # equivalent to now_utc()
$date = gmtime(); # also returns current UTC (GMT)
Table 3.69. Arguments and Return Values for gmtime()
|
Argument Type |
Return Type |
Description |
|---|---|---|
|
The date argument is converted to UTC and returned. | |
|
| ||
n/a |
If no argument is passed, then the current date and time with resolution to the second in GMT is returned. See now_utc() for a similar function that returns the current UTC time with resolution to the microsecond. |
This function does not throw any exceptions.
Table 3.70. Arguments and Return Values for hours()
|
Argument Type |
Return Type |
Description |
|---|---|---|
|
Returns a relative date/time value corresponding to the number of hours passed as an argument, to be used in date arithmetic. |
This function does not throw any exceptions.
Returns True if the argument is an absolute date/time value, False if not.
my bool $b = is_date_absolute($date);
Table 3.71. Arguments and Return Values for is_date_absolute()
|
Argument Type |
Return Type |
Description |
|---|---|---|
|
Returns |
This function does not throw any exceptions.
Returns True if the argument is an relative date/time value, False if not.
my bool $b = is_date_relative($date);
Table 3.72. Arguments and Return Values for is_date_relative()
|
Argument Type |
Return Type |
Description |
|---|---|---|
|
Returns |
This function does not throw any exceptions.
Returns the date and time in local time corresponding to the integer argument passed, which must be the number of seconds since Jan 1, 1970, 00:00:00 Z (UTC). If no argument is passed, then the current local date and time are returned.
date localtime(date $date) (CONST)
date localtime(softint $epoch_seconds, softint $microseconds = 0) (CONST)
$time = localtime(10);
Table 3.73. Arguments and Return Values for localtime()
|
Argument Type |
Return Type |
Description |
|---|---|---|
|
The date argument is converted to the local time zone and returned. | |
|
| ||
n/a |
If no argument is passed, then the current date and time with resolution to the second in the local time zone is returned. See now_us() for a similar function that returns the current local time with resolution to the microsecond. |
This function does not throw any exceptions.
Returns a relative date/time value in microseconds to be used in date arithmetic.
date microseconds(softint) (CONST)
date microseconds() (RT_NOOP)
$ms = millseconds(5 * 5); # returns 25ms
Table 3.74. Arguments and Return Values for microseconds()
|
Argument Type |
Return Type |
Description |
|---|---|---|
|
Returns a relative date/time value corresponding to the number of microseconds passed as an argument, to be used in date arithmetic. |
This function does not throw any exceptions.
Returns a relative date/time value in milliseconds to be used in date arithmetic.
date milliseconds(softint) (CONST)
date milliseconds() (RT_NOOP)
$ms = millseconds(5 * 5); # returns 25ms
Table 3.75. Arguments and Return Values for milliseconds()
|
Argument Type |
Return Type |
Description |
|---|---|---|
|
Returns a relative date/time value corresponding to the number of milliseconds passed as an argument, to be used in date arithmetic. |
This function does not throw any exceptions.
Table 3.76. Arguments and Return Values for minutes()
|
Argument Type |
Return Type |
Description |
|---|---|---|
|
Returns a relative date/time value corresponding to the number of minutes passed as an argument, to be used in date arithmetic. |
This function does not throw any exceptions.
Returns the number of seconds passed since Jan 1, 1970, 00:00:00 Z (UTC) for the date/time argument passed.
Without the RT_NOOP variant, this function is equivalent to get_epoch_seconds().
$secs = mktime(2007-09-23T00:00:01);
This function does not throw any exceptions.
Table 3.78. Arguments and Return Values for months()
|
Argument Type |
Return Type |
Description |
|---|---|---|
|
Returns a relative date/time value corresponding to the number of months passed as an argument, to be used in date arithmetic. |
This function does not throw any exceptions.
Returns the current date and time in the local time zone with resolution to the second.
For similar functions returning the current date and time in the local time zone with millisecond and microsecond resolution, see now_ms() and now_us(). Note that there is no performance penalty for using now_ms() and now_us() versus this function, this function and now_ms() are kept for backwards-compatibility.
See also now_utc().
my date $now = now();
Table 3.79. Arguments and Return Values for now()
|
Argument Type |
Return Type |
Description |
|---|---|---|
|
n/a |
Returns the current date and time in the local time zone with resolution to the second. |
This function does not throw any exceptions.
Returns the current date and time in the local time zone with resolution to the millisecond.
For a similar function returning the current date and time in the local time zone with coarser granularity, when resolution only to the second is needed, see now(); for a similar function returning the current date and time with a resolution to the microsecond, see now_us(). Note that there is no performance penalty for using now_ms() and now_us() versus now(), now() and now_ms() are kept for backwards-compatibility.
See also now_utc().
my date $now_ms = now_ms();
Table 3.80. Arguments and Return Values for now_ms()
|
Argument Type |
Return Type |
Description |
|---|---|---|
|
n/a |
Returns the current date and time in the local time zone with resolution to the millisecond. |
This function does not throw any exceptions.
Returns the current date and time in the local time zone with resolution to the microsecond.
For similar functions returning the current date and time with coarser granularity, see now() and now_ms(). Note that there is no performance impact for using now_us() versus now() and now_ms(); now() and now_ms() are kept for backwards-compatibility.
See also now_utc().
my date $now_us = now_us();
Table 3.81. Arguments and Return Values for now_us()
|
Argument Type |
Return Type |
Description |
|---|---|---|
|
n/a |
Returns the current date and time with resolution to the microsecond. |
This function does not throw any exceptions.
Table 3.82. Arguments and Return Values for now_utc()
|
Argument Type |
Return Type |
Description |
|---|---|---|
|
n/a |
Returns the current UTC date and time with resolution to the microsecond. |
This function does not throw any exceptions.
Table 3.83. Arguments and Return Values for seconds()
|
Argument Type |
Return Type |
Description |
|---|---|---|
|
Returns a relative date/time value corresponding to the number of seconds passed as an argument, to be used in date arithmetic. |
This function does not throw any exceptions.
Table 3.85. Arguments and Return Values for years()
|
Argument Type |
Return Type |
Description |
|---|---|---|
|
Returns a relative date/time value corresponding to the number of years passed as an argument, to be used in date arithmetic. |
This function does not throw any exceptions.