DateTime

A lightweight Date class

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

asDateConverts this DateTime object to a JavaScript Date object
asDateTimeGets this object as a DateTime.
getAMPMEither 'am' or 'pm.
getHoursAMPMGets this DateTime's hour.
getLetterDayNameReturns 'M', 'T', etc.
getLetterMonthNameReturns 'J', 'F', etc.
getLongDayNameGets 'Monday', 'Tuesday', etc.
getLongMonthNameReturns 'January', 'February', etc.
getPrettyDayAndTimeGets a short version of this date.
getShortDayNameReturns 'Mon', 'Tue', etc.
getShortMonthNameReturns 'Jan', 'Feb', etc.
getTimeHHMMGets the time in hours and minutes (24 hour clock).
isSameDayTrue if this Date object is in the year/month/day as otherDate.
isSameMonthReturns true if this DateTime object is in the same month as otherDate.True if this Date object is in the year/month as otherDate.
toDateStringGets a localized date string for the DateTime
toStringGets 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()

Remarks

For consistency with Date.asDateTime().

Returns

this.

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"