Documentation

Horde_Date_Utils
in package

Horde Date wrapper/logic class, including some calculation functions.

Tags
author

Chuck Hagenbuch chuck@horde.org

category

Horde

copyright

2004-2017 Horde LLC

license

http://www.horde.org/licenses/lgpl21 LGPL

Table of Contents

daysInMonth()  : int
Returns the number of days in the specified month.
firstDayOfWeek()  : Horde_Date
Returns the date of the year that corresponds to the first day of the given week.
isLeapYear()  : bool
Returns whether a year is a leap year.
legacyDateFormatter()  : void
Unify date formatters and then format the date.
relativeDateTime()  : string
Returns a relative, natural language representation of a timestamp
strftime2date()  : string
Tries to convert strftime() formatters to date() formatters.

Methods

daysInMonth()

Returns the number of days in the specified month.

public static daysInMonth(int $month, int $year) : int
Parameters
$month : int

The month

$year : int

The year.

Return values
int —

The number of days in the month.

firstDayOfWeek()

Returns the date of the year that corresponds to the first day of the given week.

public static firstDayOfWeek(int $week, int $year) : Horde_Date
Parameters
$week : int

The week of the year to find the first day of.

$year : int

The year to calculate for.

Return values
Horde_Date —

The date of the first day of the given week.

isLeapYear()

Returns whether a year is a leap year.

public static isLeapYear(int $year) : bool
Parameters
$year : int

The year.

Return values
bool —

True if the year is a leap year.

legacyDateFormatter()

Unify date formatters and then format the date.

public static legacyDateFormatter([string $pattern = 'Y-m-d H:i:s' ][, string|Horde_Date|DateTimeInterface $date = 'now' ][, mixed $timezone = null ]) : void

Facilitates upgrades from strftime to date_format style placeholders by accepting both. Some formats are not supported and will be dropped Will produce undesirable results for date_format style format strings that contain % characters

Parameters
$pattern : string = 'Y-m-d H:i:s'

A date/time format pattern either in strftime or date_format style

$date : string|Horde_Date|DateTimeInterface = 'now'
$timezone : mixed = null
Return values
void —

relativeDateTime()

Returns a relative, natural language representation of a timestamp

public static relativeDateTime(mixed $time[, string $date_format = '%x' ][, string $time_format = '%X' ]) : string
Parameters
$time : mixed

The time. Any format accepted by Horde_Date.

$date_format : string = '%x'

Format to display date if timestamp is more then 1 day old.

$time_format : string = '%X'

Format to display time if timestamp is 1 day old.

Tags
todo

Wider range of values ... maybe future time as well?

todo

Support minimum resolution parameter.

Return values
string —

The relative time (i.e. 2 minutes ago)

strftime2date()

Tries to convert strftime() formatters to date() formatters.

public static strftime2date(string $format) : string

Unsupported formatters will be removed.

Parameters
$format : string

A strftime() formatting string.

Return values
string —

A date() formatting string.

Search results