Public Member Functions | |
| __construct () | |
| Constructor (triggers an error). | |
Static Public Member Functions | |
Construction and parsing methods | |
These methods can be used to obtain an AnewtDateTimeAtom instance. There are multiple methods to parse dates in various formats. | |
| static | now () |
| Get the current date and time. | |
| static | parse ($date) |
| Parses a date into a AnewtDateTimeAtom instance. | |
| static | parse_timestamp ($timestamp) |
| Converts a timestamp into a AnewtDateTimeAtom instance. | |
| static | parse_string ($date) |
| Parses a date string and returns a AnewtDateTimeAtom instance. | |
| static | parse_ymd ($year, $month=1, $day=1) |
| Parse year, month and day integers and return a AnewtDateTimeAtom instance. | |
Validating and checking methods | |
| static | is_valid_date_ymd ($year, $month, $day) |
| Check if a date (without time) is valid. | |
| static | is_valid_time_hms ($hour, $minute, $second) |
| Check if a time (without date) is valid. | |
| static | is_valid ($date) |
| Checks if a given date is valid. | |
| static | is_current_year ($date) |
| Checks if a date is in the current year. | |
| static | is_today ($date) |
| Checks if a date is the same date as today. | |
Formatting methods | |
| static | year ($date) |
| Get the year. | |
| static | month ($date) |
| Get the month. | |
| static | day ($date) |
| Get the day. | |
| static | hour ($date) |
| Get the hours. | |
| static | minute ($date) |
| Get the minutes. | |
| static | second ($date) |
| Get the seconds. | |
| static | timestamp ($date) |
| Get a timestamp. | |
| static | format ($format, $date) |
| Formats a date in strftime()-like format. | |
| static | date ($date) |
| Get the date only. | |
| static | time ($date) |
| Get the time only. | |
| static | week ($date) |
| Get the week number. | |
| static | day_of_year ($date) |
| Get the day number in the year. | |
| static | iso8601 ($date) |
| Format the date in standard ISO 8601 format. | |
| static | iso8601_compact ($date) |
| Format the date in compact ISO 8601 format. | |
| static | iso8601_date_compact ($date) |
| Format the date in compact ISO 8601 date format. | |
| static | iso8601_time_compact ($date) |
| Format the date in compact ISO 8601 time format. | |
| static | iso8601_week ($date) |
| Format the date in ISO 8601 week format. | |
| static | iso8601_week_day ($date) |
| Format the date in ISO 8601 week and day format. | |
| static | iso8601_day_of_year ($date) |
| Format the date in ISO 8601 year-day format. | |
| static | rfc2822 ($date) |
| Format the date in RFC 2922 format. | |
| static | sql ($date) |
| Format the date in SQL92 DATETIME format. | |
| static | sql_date ($date) |
| Format the date in SQL92 DATE format. | |
| static | sql_time ($date) |
| Format the date in SQL92 TIME format. | |
| static | beat ($date) |
| Get the swatch internet time beats. | |
| static | format_if_current_year ($format_if_current_year, $format_if_not_current_year, $date) |
| Formats a date, using an alternative format if the given date is in the current year. | |
| static | format_if_today ($format_if_today, $format_if_not_today, $date) |
| Formats a date, using an alternative format if the given date is the same day as today. | |
It supports both parsing and formatting.
Definition at line 126 of file datetime.lib.php.
| AnewtDateTime::__construct | ( | ) |
Constructor (triggers an error).
This class provides only static methods.
Definition at line 131 of file datetime.lib.php.
| static AnewtDateTime::now | ( | ) | [static] |
Get the current date and time.
Definition at line 151 of file datetime.lib.php.
| static AnewtDateTime::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.
| $date | An int/string/AnewtDateTimeAtom which will be parsed. |
Definition at line 174 of file datetime.lib.php.
| static AnewtDateTime::parse_timestamp | ( | $ | timestamp | ) | [static] |
Converts a timestamp into a AnewtDateTimeAtom instance.
| $timestamp | Timestamp to use. |
Definition at line 201 of file datetime.lib.php.
| static AnewtDateTime::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.
| $date | A string specifying a date. |
Definition at line 221 of file datetime.lib.php.
| static AnewtDateTime::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.
| $year | The year (integer) | |
| $month | The month (integer, defaults to 1 if omitted) | |
| $day | The day (integer, defaults to 1 if omitted) |
Definition at line 418 of file datetime.lib.php.
| static AnewtDateTime::is_valid_date_ymd | ( | $ | year, | |
| $ | month, | |||
| $ | day | |||
| ) | [static] |
Check if a date (without time) is valid.
| $year | Year | |
| $month | Month | |
| $day | Day |
Definition at line 450 of file datetime.lib.php.
| static AnewtDateTime::is_valid_time_hms | ( | $ | hour, | |
| $ | minute, | |||
| $ | second | |||
| ) | [static] |
Check if a time (without date) is valid.
| $hour | Hour | |
| $minute | Minute | |
| $second | Second |
Definition at line 468 of file datetime.lib.php.
| static AnewtDateTime::is_valid | ( | $ | date | ) | [static] |
Checks if a given date is valid.
| $date | Any date-like object; this could be a string, timestamp or a AnewtDateTimeAtom instance. |
Definition at line 485 of file datetime.lib.php.
| static AnewtDateTime::is_current_year | ( | $ | date | ) | [static] |
Checks if a date is in the current year.
| $date | A date-like object. |
Definition at line 510 of file datetime.lib.php.
| static AnewtDateTime::is_today | ( | $ | date | ) | [static] |
Checks if a date is the same date as today.
| $date | A date-like object. |
Definition at line 524 of file datetime.lib.php.
| static AnewtDateTime::year | ( | $ | date | ) | [static] |
Get the year.
| $date | A date-like object (optional). |
Definition at line 547 of file datetime.lib.php.
| static AnewtDateTime::month | ( | $ | date | ) | [static] |
Get the month.
| $date | A date-like object (optional). |
Definition at line 566 of file datetime.lib.php.
| static AnewtDateTime::day | ( | $ | date | ) | [static] |
Get the day.
| $date | A date-like object (optional). |
Definition at line 585 of file datetime.lib.php.
| static AnewtDateTime::hour | ( | $ | date | ) | [static] |
Get the hours.
| $date | A date-like object (optional). |
Definition at line 604 of file datetime.lib.php.
| static AnewtDateTime::minute | ( | $ | date | ) | [static] |
Get the minutes.
| $date | A date-like object (optional). |
Definition at line 623 of file datetime.lib.php.
| static AnewtDateTime::second | ( | $ | date | ) | [static] |
Get the seconds.
| $date | A date-like object (optional). |
Definition at line 642 of file datetime.lib.php.
| static AnewtDateTime::timestamp | ( | $ | date | ) | [static] |
Get a timestamp.
| $date | A date-like object (optional). |
Definition at line 661 of file datetime.lib.php.
| static AnewtDateTime::format | ( | $ | format, | |
| $ | date | |||
| ) | [static] |
Formats a date in strftime()-like format.
| $format | A format specifier in strftime() syntax. | |
| $date | A date-like object (optional). |
Definition at line 682 of file datetime.lib.php.
| static AnewtDateTime::date | ( | $ | date | ) | [static] |
Get the date only.
Example: 1983-01-15.
| $date | A date-like object (optional). |
Definition at line 702 of file datetime.lib.php.
| static AnewtDateTime::time | ( | $ | date | ) | [static] |
Get the time only.
Example: 18:30:00.
| $date | A date-like object (optional). |
Definition at line 721 of file datetime.lib.php.
| static AnewtDateTime::week | ( | $ | date | ) | [static] |
Get the week number.
Example: 1983-W02.
| $date | A date-like object (optional). |
Definition at line 740 of file datetime.lib.php.
| static AnewtDateTime::day_of_year | ( | $ | date | ) | [static] |
Get the day number in the year.
Example: 15.
| $date | A date-like object (optional). |
Definition at line 759 of file datetime.lib.php.
| static AnewtDateTime::iso8601 | ( | $ | date | ) | [static] |
Format the date in standard ISO 8601 format.
Example: 1983-01-15T18:30:00.
| $date | A date-like object (optional). |
Definition at line 779 of file datetime.lib.php.
| static AnewtDateTime::iso8601_compact | ( | $ | date | ) | [static] |
Format the date in compact ISO 8601 format.
Example: 19830115T183000.
| $date | A date-like object (optional). |
Definition at line 798 of file datetime.lib.php.
| static AnewtDateTime::iso8601_date_compact | ( | $ | date | ) | [static] |
Format the date in compact ISO 8601 date format.
Example: 19830115.
| $date | A date-like object (optional). |
Definition at line 817 of file datetime.lib.php.
| static AnewtDateTime::iso8601_time_compact | ( | $ | date | ) | [static] |
Format the date in compact ISO 8601 time format.
Example: 183000.
| $date | A date-like object (optional). |
Definition at line 836 of file datetime.lib.php.
| static AnewtDateTime::iso8601_week | ( | $ | date | ) | [static] |
Format the date in ISO 8601 week format.
Example: 1983-W02.
| $date | A date-like object (optional). |
Definition at line 855 of file datetime.lib.php.
| static AnewtDateTime::iso8601_week_day | ( | $ | date | ) | [static] |
Format the date in ISO 8601 week and day format.
Example: 1983-W02-6.
| $date | A date-like object (optional). |
Definition at line 874 of file datetime.lib.php.
| static AnewtDateTime::iso8601_day_of_year | ( | $ | date | ) | [static] |
Format the date in ISO 8601 year-day format.
Example: 1983-015.
| $date | A date-like object (optional). |
Definition at line 893 of file datetime.lib.php.
| static AnewtDateTime::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.
| $date | A date-like object (optional). |
Definition at line 913 of file datetime.lib.php.
| static AnewtDateTime::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.
| $date | A date-like object (optional). |
Definition at line 936 of file datetime.lib.php.
| static AnewtDateTime::sql_date | ( | $ | date | ) | [static] |
Format the date in SQL92 DATE format.
Example: 1983-01-15. This format can be used in SQL queries.
| $date | A date-like object (optional). |
Definition at line 959 of file datetime.lib.php.
| static AnewtDateTime::sql_time | ( | $ | date | ) | [static] |
Format the date in SQL92 TIME format.
Example: 18:30:00. This format can be used in SQL queries.
| $date | A date-like object (optional). |
Definition at line 982 of file datetime.lib.php.
| static AnewtDateTime::beat | ( | $ | date | ) | [static] |
Get the swatch internet time beats.
| $date | A date-like object (optional). |
@000 format. Definition at line 1001 of file datetime.lib.php.
| static AnewtDateTime::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_year | A format specifier in strftime() syntax, used if the date is in the current year. | |
| $format_if_not_current_year | A format specifier in strftime() syntax, used if the date is not in the current year. | |
| $date | A date-like object (optional). |
Definition at line 1030 of file datetime.lib.php.
| static AnewtDateTime::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_today | A format specifier in strftime() syntax, used if the date is today. | |
| $format_if_not_today | A format specifier in strftime() syntax, used if the date is not today. | |
| $date | A date-like object (optional). |
Definition at line 1062 of file datetime.lib.php.
1.5.9