DateHelper
class DateHelper (View source)
Defines Gregorian Calendar date values.
Lots of helpful functions for use in massaging dates, specific to the Gregorian calendar system. The values include both translated and untranslated values.
Untranslated values are useful as array keys and as css identifiers, and should be listed in English.
Translated values are useful for display to the user. All values that need translation should be hard-coded and wrapped in t() so the translation system will be able to process them.
Methods
Constructs an untranslated array of month names.
Constructs an untranslated array of abbreviated month names.
Returns a translated array of month names.
Constructs a translated array of month name abbreviations.
Constructs an untranslated array of week days.
Returns a translated array of week names.
Constructs a translated array of week day abbreviations.
Constructs a translated array of 2-letter week day abbreviations.
Constructs a translated array of 1-letter week day abbreviations.
Reorders weekdays to match the first day of the week.
Constructs an array of years in a specified range.
Constructs an array of days in a month.
Constructs an array of hours.
Constructs an array of minutes.
Constructs an array of seconds.
Constructs an array of AM and PM options.
Identifies the number of days in a month for a date.
Identifies the number of days in a year for a date.
Returns day of week for a given date (0 = Sunday).
Returns translated name of the day of week for a given date.
Details
static array
monthNamesUntranslated()
Constructs an untranslated array of month names.
static array
monthNamesAbbrUntranslated()
Constructs an untranslated array of abbreviated month names.
static array
monthNames(bool $required = FALSE)
Returns a translated array of month names.
static array
monthNamesAbbr(bool $required = FALSE)
Constructs a translated array of month name abbreviations.
static array
weekDaysUntranslated()
Constructs an untranslated array of week days.
static array
weekDays(bool $required = FALSE)
Returns a translated array of week names.
static array
weekDaysAbbr(bool $required = FALSE)
Constructs a translated array of week day abbreviations.
static array
weekDaysAbbr2(bool $required = FALSE)
Constructs a translated array of 2-letter week day abbreviations.
static array
weekDaysAbbr1(bool $required = FALSE)
Constructs a translated array of 1-letter week day abbreviations.
static array
weekDaysOrdered(array $weekdays)
Reorders weekdays to match the first day of the week.
static array
years(int $min = 0, int $max = 0, bool $required = FALSE)
Constructs an array of years in a specified range.
static array
days(bool $required = FALSE, int $month = NULL, int $year = NULL)
Constructs an array of days in a month.
static array
hours(string $format = 'H', bool $required = FALSE)
Constructs an array of hours.
static array
minutes(string $format = 'i', bool $required = FALSE, int $increment = 1)
Constructs an array of minutes.
static array
seconds(string $format = 's', bool $required = FALSE, int $increment = 1)
Constructs an array of seconds.
static array
ampm(bool $required = FALSE)
Constructs an array of AM and PM options.
static int
daysInMonth(mixed $date = NULL)
Identifies the number of days in a month for a date.
static int
daysInYear(mixed $date = NULL)
Identifies the number of days in a year for a date.
static int
dayOfWeek(mixed $date = NULL)
Returns day of week for a given date (0 = Sunday).
static string
dayOfWeekName(mixed $date = NULL, string $abbr = TRUE)
Returns translated name of the day of week for a given date.