Object that represents a date and time value with timezone and its related operations.
All the class methods are based and expect values that follow the ISO 8601 format, which is the international standard for the
representation of dates and times. Any other date/time format will be considered as invalid.
Following is an example of a valid ISO 8601 dateTime value:
yyyy-mm-ddTHH:MM:SS.UUU+TT:TT
where:
IMPORTANT: It is highly recommended to always physically store your datetime values as UTC (aka 00 timezone offset). The local timezone offset should be applied only when showing the datetime values to the user. All the other date and time usages of your application should be performed with UTC values.
A string containing a valid ISO 8601 date/time value that will be used to initialize this instance. If string is empty, the current system date/time WITH UTC TIMEZONE will be used. If string is incomplete, all missing parts will be filled with the lowest possible value. If timezone offset is missing, UTC will be used.
The created instance
The date and time values that are stored on this instance are saved as an ISO 8601 string
An exploded version of this instance _dateTimeString ISO string, that is used to improve performance when reading some of the date values
Auxiliary method that is used to generate an array with all the values that are defined on an ISO 8601 string
A valid ISO 8601 string
An array with all the date time values extracted
Compares the current datetime instance value to the given one and tells if they are exactly the same or which one represents a later time value than the other. Timezones from the both dateTime values are taken into consideration for the comparison.
A valid ISO 8601 dateTime value or a DateTimeObject instance.
0 If the two dateTime values represent the exact same time, 1 if this instance > dateTime or 2 if dateTime > this instance
Get this instance's defined day as a numeric value from 1 to 31
A value between 1 and 31
Get this instance's defined day of week as a numeric value from 1 to 7, where Sunday is considered
to be the first one:
1 = Sunday, 2 = Monday, 3 = Tuesday, etc ...
A numeric value between 1 and 7
Get the first day of month for the current dateTime value.
A dateTime object representing the first day of month based on the current instance
Get this instance's defined hour as a numeric value from 0 to 23
A value between 0 and 23
Get the last day of month for the current dateTime value.
A dateTime object representing the last day of month based on the current instance
Get this instance's defined microseconds as a numeric value up to 6 digit
A value up to 6 digit
Get this instance's defined miliseconds as a numeric value up to 3 digit
A value up to 3 digit
Get this instance's defined minute as a numeric value from 0 to 59
A value between 0 and 59
Get this instance's defined month as a numeric value from 1 to 12
A value between 1 and 12
Get this instance's defined second as a numeric value from 0 to 59
A value between 0 and 59
Get this instance's defined timezone offset as a numeric value (in seconds)
The UTC timezone offset in seconds
Get this instance's defined year as a numeric value
A 4 digits numeric value
Check if the provided ISO 8601 dateTime value is identical to the date and time from this instance
A valid ISO 8601 dateTime string or a DateTimeObject instance.
True if both dateTime values are equivalent to the exact same date and time
Check if the current instance timezone is the UTC +00:00 value
True if the instance timezone is UTC, false if not
Convert the current instance date and time values to the local timezone offset.
This object instance
Convert the current instance date and time values to the UTC zero timezone offset.
This object instance
Output the current dateTime instance data as a custom formatted string (by default a full ISO 8601 string).
A string containing the output format like 'd/m/Y' or 'm-d-y'
where the following characters will be automatically replaced:
The dateTime with the specified format.
This method compares two dateTime values and tells if they are exactly the same or which one represents a later time value than the other. Timezones from the specified dateTime values are taken into consideration for the comparison.
A valid ISO 8601 dateTime value or a DateTimeObject instance.
A valid ISO 8601 dateTime value or a DateTimeObject instance.
0 If the two dateTime values represent the exact same time, 1 if dateTime1 > dateTime2 or 2 if dateTime2 > dateTime1
Get the day based on current system date and timezone as a numeric value from 1 to 31
The day of month as a value between 1 and 31
Get the numeric day of week (between 1 and 7) based on current system time, where Sunday is considered
to be the first one:
1 = Sunday, 2 = Monday, 3 = Tuesday, etc ...
A numeric value between 1 and 7 (where Sunday is 1, Monday is 2, ...)
Get the hour based on current system date and timezone as a numeric value from 0 to 23
The hour as a value between 0 and 23
Get the microseconds based on current system date and timezone as a numeric value up to 6 digits
The microseconds as a value up to 6 digits
Get the miliseconds based on current system date and timezone as a numeric value up to 3 digits
The miliseconds as a value up to 3 digits
Get the minute based on current system date and timezone as a numeric value from 0 to 59
The minute as a value between 0 and 59
Get the month based on current system date and timezone as a numeric value from 1 to 12
A value between 1 and 12
Get the seconds based on current system date and timezone as a numeric value from 0 to 59
The seconds as a value between 0 and 59
Get the timezone offset based on current system date and timezone as a numeric value (in seconds)
The timezone offset as a numeric value in seconds
Get the year based on current system date and timezone
A numeric value representing the current year
Get the english name representing the given numeric value of a week day (between 1 and 7), where Sunday is considered to be the first one: 1 = Sunday, 2 = Monday, 3 = Tuesday, etc ...
A day number between 1 and 7
The day name in english and with capital letters, like for example: MONDAY, SATURDAY...
Returns the month name from a numeric month value
A month number between 1 and 12
the month name in english and with capital letters, like: JANUARY, FEBRUARY, ...
Given two valid dateTime values, this method will check if they represent the same date and time value
A valid ISO 8601 dateTime string or a DateTimeObject instance.
A valid ISO 8601 dateTime string or a DateTimeObject instance.
True if the date and time values on both elements are the same
DateTimeObject class operates only with ISO 8601 strings, which is the international standard for the representation of dates and times. Therefore, this method considers a dateTime string value to be valid only if it is a string that follows that standard or a DateTimeObject instance.
A string containing a valid ISO 8601 date/time value or a valid DateTimeObject instance.
true if the specified value is ISO 8601 or a DateTimeObject instance, false if value contains invalid information.
Generated using TypeDoc
date and time format object abstraction based on ISO 8601 standard TODO - This is a first implementation of this class which must be strictly tested and completed by taking the php version as a reference