DateTime
A lightweight Date class
- Object
- DateTime
Remarks
DateTime mirrors the Date class, but stores the date using a series of
properties rather than an "epoch". This is useful on FireFox,
where it is several hundred times slower to get
a year/month/day from a Date than a
simple property access.
Methods
asDate | Converts this DateTime object to a JavaScript Date object |
asDateTime | Gets this object as a DateTime. |
getAMPM | Either 'am' or 'pm. |
getHoursAMPM | Gets this DateTime's hour. |
getLetterDayName | Returns 'M', 'T', etc. |
getLetterMonthName | Returns 'J', 'F', etc. |
getLongDayName | Gets 'Monday', 'Tuesday', etc. |
getLongMonthName | Returns 'January', 'February', etc. |
getPrettyDayAndTime | Gets a short version of this date. |
getShortDayName | Returns 'Mon', 'Tue', etc. |
getShortMonthName | Returns 'Jan', 'Feb', etc. |
getTimeHHMM | Gets the time in hours and minutes (24 hour clock). |
isSameDay | True if this Date object is in the year/month/day as otherDate. |
isSameMonth | Returns true if this DateTime object is in the same month as otherDate.True if this Date object is in the year/month as otherDate. |
toDateString | Gets a localized date string for the DateTime |
toString | Gets a standard ISO 8601 DateTime Encoding for the DateTime |
DateTime asDate method
Converts this DateTime object to a JavaScript Date object
JavaScript
var date = dateTime.asDate()
Returns
A JavaScript Date.
DateTime asDateTime method
Gets this object as a DateTime.
JavaScript
var dateTime = dateTime.asDateTime()
DateTime getAMPM method
Either 'am' or 'pm.
JavaScript
var strVal = dateTime.getAMPM()
Returns
'am' if this hour is less than 12, 'pm' otherwise.
DateTime getHoursAMPM method
Gets this DateTime's hour.
JavaScript
var intVal = dateTime.getHoursAMPM()
Returns
An integer between 1 and 12.
DateTime getLetterDayName method
Returns 'M', 'T', etc.
JavaScript
var strVal = dateTime.getLetterDayName()
Returns
The a single-letter representation of this DateTime's day.
DateTime getLetterMonthName method
Returns 'J', 'F', etc.
JavaScript
var strVal = dateTime.getLetterMonthName()
Returns
The single-letter representation of this DateTime's month.
DateTime getLongDayName method
Gets 'Monday', 'Tuesday', etc.
JavaScript
var strVal = dateTime.getLongDayName()
Returns
The long string representation of this DateTime's day.
DateTime getLongMonthName method
Returns 'January', 'February', etc.
JavaScript
var strVal = dateTime.getLongMonthName()
Returns
The long representation of this DateTime's month.
DateTime getPrettyDayAndTime method
Gets a short version of this date.
JavaScript
var strVal = dateTime.getPrettyDayAndTime()
Returns
Returns a string presentation of this DateTime.
DateTime getShortDayName method
Returns 'Mon', 'Tue', etc.
JavaScript
var strVal = dateTime.getShortDayName()
Returns
The short string representation of this DateTime's day.
DateTime getShortMonthName method
Returns 'Jan', 'Feb', etc.
JavaScript
var strVal = dateTime.getShortMonthName()
Returns
The short representation of this DateTime's month.
DateTime getTimeHHMM method
Gets the time in hours and minutes (24 hour clock).
JavaScript
var strVal = dateTime.getTimeHHMM()
Returns
A string like '13:07'
DateTime isSameDay method
True if this Date object is in the year/month/day as otherDate.
JavaScript
var boolVal = dateTime.isSameDay(otherDate)
Remarks
otherDate can either be a DateTime or a Date.
Returns
true if the two dates share the same day, false otherwise.
DateTime isSameMonth method
Returns true if this DateTime object is in the same month as otherDate.True if this Date object is in the year/month as otherDate.
JavaScript
var boolVal = dateTime.isSameMonth(otherDate)
Remarks
otherDate can either be a DateTime or a Date.
Returns
true if the two dates share the same month and year, false otherwise.
DateTime toDateString method
Gets a localized date string for the DateTime
JavaScript
var strVal = dateTime.toDateString()
Returns
A localized string.
DateTime toString method
Gets a standard ISO 8601 DateTime Encoding for the DateTime
JavaScript
var strVal = dateTime.toString()
Returns
A string of the form "yyyy-mm-ddThh:mm:ssZ"