This class provides methods for date and time operations.
This class provides methods for date and time operations.
It supports both parsing and formatting.
These methods can be used to obtain an AnewtDateTimeAtom instance. There are multiple methods to parse dates in various formats.
static now() [static] ¶Get the current date and time.
AnewtDateTimeAtom representing the current date.
static parse($date) [static] ¶Parses a date into a AnewtDateTimeAtom instance.
The function also accepts AnewtDateTimeAtom instances. In that case the supplied instance is returned. If parsing fails, null is returned.
Note that in many cases you should just call one of the more specific parsing methods instead.
$dateAn int/string/AnewtDateTimeAtom which will be parsed.
A newly created AnewtDateTimeAtom instance or null if parsing failed.
static parse_timestamp($timestamp) [static] ¶Converts a timestamp into a AnewtDateTimeAtom instance.
$timestampTimestamp to use.
A newly created AnewtDateTimeAtom instance or null if parsing failed.
static parse_string($date) [static] ¶Parses a date string and returns a AnewtDateTimeAtom instance.
This method supports many common date and time formats, including SQL's DATETIME and several ISO 8601 forms.
$dateA string specifying a date.
A newly created AnewtDateTimeAtom instance or null if parsing failed.
static parse_ymd($year, $month=1, $day=1) [static] ¶Parse year, month and day integers and return a AnewtDateTimeAtom instance.
This method is useful if you want to transform year, month and day values into an AnewtDateTimeAtom instance.
$yearThe year (integer)
$monthThe month (integer, defaults to 1 if omitted)
$dayThe day (integer, defaults to 1 if omitted)
A newly created AnewtDateTimeAtom instance or null if parsing failed.
static is_valid_date_ymd($year, $month, $day) [static] ¶Check if a date (without time) is valid.
$yearYear
$monthMonth
$dayDay
True if this is a valid date, false otherwise.
static is_valid_time_hms($hour, $minute, $second) [static] ¶Check if a time (without date) is valid.
$hourHour
$minuteMinute
$secondSecond
True if this is a valid time, false otherwise.
static is_valid($date) [static] ¶Checks if a given date is valid.
$dateAny date-like object; this could be a string, timestamp or a AnewtDateTimeAtom instance.
True if this is a valid date, false otherwise.
static is_current_year($date) [static] ¶Checks if a date is in the current year.
$dateA date-like object.
True if the given date is in the current year, false otherwise.
static is_today($date) [static] ¶Checks if a date is the same date as today.
$dateA date-like object.
True if the date is today, false otherwise.
static year($date) [static] ¶Get the year.
$dateA date-like object (optional).
The year of the given date.
static month($date) [static] ¶Get the month.
$dateA date-like object (optional).
The month of the given date.
static day($date) [static] ¶Get the day.
$dateA date-like object (optional).
The day of the given date.
static hour($date) [static] ¶Get the hours.
$dateA date-like object (optional).
The hours of the given date.
static minute($date) [static] ¶Get the minutes.
$dateA date-like object (optional).
The minutes of the given date.
static second($date) [static] ¶Get the seconds.
$dateA date-like object (optional).
The seconds of the given date.
static timestamp($date) [static] ¶Get a timestamp.
$dateA date-like object (optional).
A timestamp representing the given date.
static format($format, $date) [static] ¶Formats a date in strftime()-like format.
$formatA format specifier in strftime() syntax.
$dateA date-like object (optional).
A formatted date representation.
static date($date) [static] ¶Get the date only.
Example: 1983-01-15.
$dateA date-like object (optional).
A string in yyyy-mm-dd format.
static time($date) [static] ¶Get the time only.
Example: 18:30:00.
$dateA date-like object (optional).
A string in hh:mm:ss format.
static week($date) [static] ¶Get the week number.
Example: 1983-W02.
$dateA date-like object (optional).
An integer denoting the week number of this year.
static day_of_year($date) [static] ¶Get the day number in the year.
Example: 15.
$dateA date-like object (optional).
An integer denoting the day number of this year.
static iso8601($date) [static] ¶Format the date in standard ISO 8601 format.
Example: 1983-01-15T18:30:00.
$dateA date-like object (optional).
A string in yyyy-mm-ddThh:mm:ss format.
static iso8601_compact($date) [static] ¶Format the date in compact ISO 8601 format.
Example: 19830115T183000.
$dateA date-like object (optional).
A string in yyyymmddThhmmss format.
static iso8601_date_compact($date) [static] ¶Format the date in compact ISO 8601 date format.
Example: 19830115.
$dateA date-like object (optional).
A string in yyyymmdd format.
static iso8601_time_compact($date) [static] ¶Format the date in compact ISO 8601 time format.
Example: 183000.
$dateA date-like object (optional).
A string in hhmmss format.
static iso8601_week($date) [static] ¶Format the date in ISO 8601 week format.
Example: 1983-W02.
$dateA date-like object (optional).
A string in yyyy-Wnn format.
static iso8601_week_day($date) [static] ¶Format the date in ISO 8601 week and day format.
Example: 1983-W02-6.
$dateA date-like object (optional).
A string in yyyy-Wnn-m format.
static iso8601_day_of_year($date) [static] ¶Format the date in ISO 8601 year-day format.
Example: 1983-015.
$dateA date-like object (optional).
A string in yyyy-nnn format.
static rfc2822($date) [static] ¶Format the date in RFC 2922 format.
Example: Sat, 15 Jan 1983 18:30:00 +0100. This format can be used for e-mail messages or RSS 2 feeds.
$dateA date-like object (optional).
A string in yyyy-nnn format.
static sql($date) [static] ¶Format the date in SQL92 DATETIME format.
Example: 1983-01-15 18:30:00. This format can be used in SQL queries.
$dateA date-like object (optional).
A string in yyyy-mm-dd hh:mm:ss format.
static sql_date($date) [static] ¶Format the date in SQL92 DATE format.
Example: 1983-01-15. This format can be used in SQL queries.
$dateA date-like object (optional).
A string in yyyy-mm-dd format.
static sql_time($date) [static] ¶Format the date in SQL92 TIME format.
Example: 18:30:00. This format can be used in SQL queries.
$dateA date-like object (optional).
A string in hh:mm:ss format.
static beat($date) [static] ¶Get the swatch internet time beats.
$dateA date-like object (optional).
A string in @000 format.
static format_if_current_year($format_if_current_year, $format_if_not_current_year, $date) [static] ¶Formats a date, using an alternative format if the given date is in the current year.
$format_if_current_yearA format specifier in strftime() syntax, used if the date is in the current year.
$format_if_not_current_yearA format specifier in strftime() syntax, used if the date is not in the current year.
$dateA date-like object (optional).
A formatted date representation.
static format_if_today($format_if_today, $format_if_not_today, $date) [static] ¶Formats a date, using an alternative format if the given date is the same day as today.
$format_if_todayA format specifier in strftime() syntax, used if the date is today.
$format_if_not_todayA format specifier in strftime() syntax, used if the date is not today.
$dateA date-like object (optional).
A formatted date representation.