Returns the offset (in seconds) between two time zones. Use this to display dates to users in different time zones.
Parameters
Returns
Example
$seconds = Date::offset('America/Chicago', 'GMT');
Number of seconds in a minute, incrementing by a step. Typically used as a shortcut for generating a list that can used in a form.
Params
Returns
Example
$seconds = Date::seconds(); // 01, 02, 03, ..., 58, 59, 60
Number of minutes in an hour, incrementing by a step. Typically used as a shortcut for generating a list that can be used in a form.
Parameters
Returns
Example
$minutes = Date::minutes(); // 05, 10, 15, ..., 50, 55, 60
Number of hours in a day. Typically used as a shortcut for generating a list.
Parameters
Returns
Example
$hours = Date::hours(); // 01, 02, 03, ..., 10, 11, 12
Returns AM or PM, based on a given hour (in 24 hour format).
Parameters
Returns
Example
$type = Date::ampm(12); // PM $type = Date::ampm(1); // AM
Adjusts a non-24-hour number into a 24-hour number.
Parameters
Returns
Example
$hour = Date::adjust(3, 'pm'); // 15
Number of days in a given month and year. Typically used as a shortcut for generating a list that can be used in a form.
Parameters
Returns
Example
Date::days(4, 2017); // 1, 2, 3, ..., 28
Number of months in a year. Typically used as a shortcut for generating a list.
Parameters
Returns
Example
// By default a mirrored array of $month_number => $month_number is returned
Date::months(); // [1 => 1, 2 => 2, 3 => 3, ..., 12 => 12]
// But you can customize this by passing in either Date:;MONTHS_LONG
Date::months(Date::MONTHS_LONG); // [1 => 'January', 2 => 'February'...]
// or Date::MONTHS_SHORT
Date::months(Date::MONTHS_SHORT); // [1 => 'Jan', 2 => 'Feb'...]
Returns an array of years between a starting and ending year. By default, the the current year - 5 and current year + 5 will be used. Typically used as a shortcut for generating a list.
Parameters
Returns
Example
$years = Date::years(2000, 2010); // 2000, 2001, ..., 2009, 2010
Returns time difference between two timestamps, in human readable format. If the second timestamp is not given, the current time will be used. Also consider using [Date::fuzzy_span] when displaying a span.
Parameters
Returns
Example
$span = Date::span(60, 182, 'minutes,seconds'); // array('minutes' => 2, 'seconds' => 2)
$span = Date::span(60, 182, 'minutes'); // 2
Returns the difference between a time and now in a "fuzzy" way. Displaying a fuzzy time instead of a date is usually faster to read and understand.
Parameters
Returns
Example
$span = Date::fuzzy_span(time() - 10); // "moments ago"
$span = Date::fuzzy_span(time() + 20); // "in moments"
Returns a date/time string with the specified timestamp format.
Parameters
Returns
Example
$time = Date::formatted_time('5 minutes ago');