expDateTime
in package
This is the class expDateTime These methods do NOT take timezones into consideration unless documented otherwise
Tags
Table of Contents
- convertPhpToJsMomentFormat() : string
- Converts php DateTime format to Javascript Moment format
- date_format_to() : bool|string
- Convert date/time format between `date()` and `strftime()`
- duration() : array<string|int, mixed>
- exdoc Looks at a start and end time and figures out how many seconds elapsed since between the earlier timestamp and the later timestamp. It doesn't matter if the bigger argument is specified first or not. Returns the number of seconds between $time_a and $time_b
- endOfDayTimestamp() : int
- exdoc Looks at a timestamp and returns another timestamp representing 11:59:59 pm of the same day.
- endOfMonthDay() : int
- exdoc Looks at a timestamp and returns the date of the last day. For instance, if the passed timestamp was in January, this function would return 31. Leap year is taken into account.
- endOfMonthTimestamp() : int
- exdoc Given a timestamp, this function will calculate another timestamp that represents the end of the month that the passed timestamp falls into. For instance, passing a timestamp representing January 25th 1984 would return a timestamp representing January 31st 1984, at 11:59pm.
- endOfWeekTimestamp() : int
- exdoc Looks at a timestamp and returns another timestamp representing 12:00:01 am of the DISPLAY_START_OF_WEEK day of the same week.
- endOfYearTimestamp() : int
- exdoc Given a timestamp, this function will calculate another timestamp that represents the end of the year that the passed timestamp falls into. For instance, passing a timestamp representing January 25th 1984 would return a timestamp representing December 31st 1984, at 11:59pm.
- format_date() : string
- Return a date in the preferred format
- is_date() : mixed
- monthlyDaysTimestamp() : array<string|int, mixed>
- exdoc Adapted from calendar module's minical view to be more modular.
- monthsDropdown() : string
- exdoc
- recurringDailyDates() : array<string|int, mixed>
- exdoc Find all of the dates that fall within the daily recurrence criteria.
- recurringMonthlyDates() : array<string|int, mixed>
- exdoc Finds all of the dates that fall within the monthly recurrence criteria and within the $start to $end timestamp range. Monthly recurrence can be done on a specific date (the 14th of the month) or on a specific weekday / offset pair (the third sunday of the month).
- recurringWeeklyDates() : array<string|int, mixed>
- exdoc Finds all of the dates that fall within the weekly recurrence criteria (namely, which weekdays) and within the $start to $end timestamp range.
- recurringYearlyDates() : array<string|int, mixed>
- exdoc Finds all of the dates that fall within the yearly recurrence criteria (similar to monthly) and within the $start to $end timestamp range.
- relativeDate() : string
- Returns date as a relative phrase (2 days ago, etc..)
- sameDay() : bool
- Function to check if dates are same day
- startOfDayTimestamp() : int
- exdoc Looks at a timestamp and returns another timestamp representing 12:00:01 am of the same day.
- startOfMonthTimestamp() : int
- exdoc Given a timestamp, this function will calculate another timestamp that represents the beginning of the month that the passed timestamp falls into. For instance, passing a timestamp representing January 25th 1984 would return a timestamp representing January 1st 1984, at 12:00am.
- startOfWeekTimestamp() : int
- exdoc Looks at a timestamp and returns another timestamp representing 12:00:01 am of the DISPLAY_START_OF_WEEK day of the same week.
- startOfYearTimestamp() : int
- exdoc Given a timestamp, this function will calculate another timestamp that represents the beginning of the year that the passed timestamp falls into. For instance, passing a timestamp representing January 25th 1984 would return a timestamp representing January 1st 1984, at 12:00am.
Methods
convertPhpToJsMomentFormat()
Converts php DateTime format to Javascript Moment format
public
static convertPhpToJsMomentFormat(string $phpFormat) : string
Parameters
- $phpFormat : string
Return values
string —date_format_to()
Convert date/time format between `date()` and `strftime()`
public
static date_format_to(string $format, string $syntax) : bool|string
Timezone conversion is done for Unix. Windows users must exchange %z and %Z.
Unsupported date formats : S, n, t, L, B, G, u, e, I, P, Z, c, r Unsupported strftime formats : %U, %W, %C, %g, %r, %R, %T, %X, %c, %D, %F, %x
Parameters
- $format : string
-
The format to parse.
- $syntax : string
-
The format's syntax. Either 'strf' for
strtime()
or 'date' fordate()
.
Tags
Return values
bool|string —Returns a string formatted according $syntax using the given $format or false
.
duration()
exdoc Looks at a start and end time and figures out how many seconds elapsed since between the earlier timestamp and the later timestamp. It doesn't matter if the bigger argument is specified first or not. Returns the number of seconds between $time_a and $time_b
public
static duration(int $time_a, int $time_b[, bool $iso8601 = false ]) : array<string|int, mixed>
Parameters
- $time_a : int
-
The first timestamp
- $time_b : int
-
The second timestamp
- $iso8601 : bool = false
-
return duration as an iso8601 string
Tags
Return values
array<string|int, mixed> —endOfDayTimestamp()
exdoc Looks at a timestamp and returns another timestamp representing 11:59:59 pm of the same day.
public
static endOfDayTimestamp(int $timestamp) : int
Parameters
- $timestamp : int
-
The timestamp to check.
Tags
Return values
int —endOfMonthDay()
exdoc Looks at a timestamp and returns the date of the last day. For instance, if the passed timestamp was in January, this function would return 31. Leap year is taken into account.
public
static endOfMonthDay(int $timestamp) : int
Parameters
- $timestamp : int
-
The timestamp to check.
Tags
Return values
int —endOfMonthTimestamp()
exdoc Given a timestamp, this function will calculate another timestamp that represents the end of the month that the passed timestamp falls into. For instance, passing a timestamp representing January 25th 1984 would return a timestamp representing January 31st 1984, at 11:59pm.
public
static endOfMonthTimestamp(int $timestamp) : int
Parameters
- $timestamp : int
-
The original timestamp to use when calculating.
Tags
Return values
int —endOfWeekTimestamp()
exdoc Looks at a timestamp and returns another timestamp representing 12:00:01 am of the DISPLAY_START_OF_WEEK day of the same week.
public
static endOfWeekTimestamp(int $timestamp) : int
Parameters
- $timestamp : int
-
The timestamp to check.
Tags
Return values
int —endOfYearTimestamp()
exdoc Given a timestamp, this function will calculate another timestamp that represents the end of the year that the passed timestamp falls into. For instance, passing a timestamp representing January 25th 1984 would return a timestamp representing December 31st 1984, at 11:59pm.
public
static endOfYearTimestamp(int $timestamp) : int
Parameters
- $timestamp : int
-
The original timestamp to use when calculating.
Tags
Return values
int —format_date()
Return a date in the preferred format
public
static format_date(mixed $timestamp[, string $format = DISPLAY_DATE_FORMAT ]) : string
Parameters
- $timestamp : mixed
- $format : string = DISPLAY_DATE_FORMAT
Return values
string —is_date()
public
static is_date(mixed $str) : mixed
Parameters
- $str : mixed
Return values
mixed —monthlyDaysTimestamp()
exdoc Adapted from calendar module's minical view to be more modular.
public
static monthlyDaysTimestamp([null $time = null ]) : array<string|int, mixed>
Parameters
- $time : null = null
Return values
array<string|int, mixed> —monthsDropdown()
exdoc
public
static monthsDropdown( $controlName, $default_month) : string
Parameters
Tags
Return values
string —recurringDailyDates()
exdoc Find all of the dates that fall within the daily recurrence criteria.
public
static recurringDailyDates(int $start, int $end, int $freq) : array<string|int, mixed>
This is the simplest form of recurrence, events are spaced a given number of days apart.
Parameters
- $start : int
-
The start of the recurrence range
- $end : int
-
The end of the recurrence range
- $freq : int
-
Frequency of recurrence - 2 means every 2 days, and 1 means every day.
Tags
Return values
array<string|int, mixed> —recurringMonthlyDates()
exdoc Finds all of the dates that fall within the monthly recurrence criteria and within the $start to $end timestamp range. Monthly recurrence can be done on a specific date (the 14th of the month) or on a specific weekday / offset pair (the third sunday of the month).
public
static recurringMonthlyDates(int $start, int $end, int $freq[, bool $by_day = false ]) : array<string|int, mixed>
Parameters
- $start : int
-
The start of the recurrence range
- $end : int
-
The end of the recurrence range
- $freq : int
-
Monthly frequency - 1 means every month, 2 means every other month, etc.
- $by_day : bool = false
-
Whether or not to recur by the weekday and week offset (in case of true), or by the date (in case of false).
Tags
Return values
array<string|int, mixed> —recurringWeeklyDates()
exdoc Finds all of the dates that fall within the weekly recurrence criteria (namely, which weekdays) and within the $start to $end timestamp range.
public
static recurringWeeklyDates(int $start, int $end, int $freq, array<string|int, mixed> $days) : array<string|int, mixed>
For a technical discussion of this function and the mathematics involved, please see the sdk/analysis/subsystems/datetime.txt file.
Parameters
- $start : int
-
The start of the recurrence range
- $end : int
-
The end of the recurrence range
- $freq : int
-
Weekly frequency - 1 means every week, 2 means every other week, etc.
- $days : array<string|int, mixed>
-
The weekdays (in integer notation, 0 = Sunday, etc.) that should be matched. A MWF recurrence rotation would contain the values 1,3 and 5.
Tags
Return values
array<string|int, mixed> —recurringYearlyDates()
exdoc Finds all of the dates that fall within the yearly recurrence criteria (similar to monthly) and within the $start to $end timestamp range.
public
static recurringYearlyDates(int $start, int $end, int $freq) : array<string|int, mixed>
Unlike monthly recurrence, yearly cannot do recurrence like 'the 17th sunday of the year'.
Parameters
- $start : int
-
The start of the recurrence range
- $end : int
-
The end of the recurrence range
- $freq : int
-
Yearly frequency - 1 means every year, 2 means every other year, etc.
Tags
Return values
array<string|int, mixed> —relativeDate()
Returns date as a relative phrase (2 days ago, etc..)
public
static relativeDate( $posted_date) : string
Parameters
Return values
string —sameDay()
Function to check if dates are same day
public
static sameDay( $date1, $date2) : bool
Parameters
Return values
bool —startOfDayTimestamp()
exdoc Looks at a timestamp and returns another timestamp representing 12:00:01 am of the same day.
public
static startOfDayTimestamp(int $timestamp) : int
Parameters
- $timestamp : int
-
The timestamp to check.
Tags
Return values
int —startOfMonthTimestamp()
exdoc Given a timestamp, this function will calculate another timestamp that represents the beginning of the month that the passed timestamp falls into. For instance, passing a timestamp representing January 25th 1984 would return a timestamp representing January 1st 1984, at 12:00am.
public
static startOfMonthTimestamp(int $timestamp) : int
Parameters
- $timestamp : int
-
The original timestamp to use when calculating.
Tags
Return values
int —startOfWeekTimestamp()
exdoc Looks at a timestamp and returns another timestamp representing 12:00:01 am of the DISPLAY_START_OF_WEEK day of the same week.
public
static startOfWeekTimestamp(int $timestamp) : int
Parameters
- $timestamp : int
-
The timestamp to check.
Tags
Return values
int —startOfYearTimestamp()
exdoc Given a timestamp, this function will calculate another timestamp that represents the beginning of the year that the passed timestamp falls into. For instance, passing a timestamp representing January 25th 1984 would return a timestamp representing January 1st 1984, at 12:00am.
public
static startOfYearTimestamp(int $timestamp) : int
Parameters
- $timestamp : int
-
The original timestamp to use when calculating.