API Documentation

class DateTime

The DateTime object provides an interface for working with dates and times in various formats. DateTime also provides methods for calendar operations, date and time arithmetic and formatting.

DateTime objects represent instants in time and provide interfaces for controlling its representation without affecting the absolute value of the object.

DateTime objects may be created from a wide variety of string or numeric data, or may be computed from other DateTime objects. DateTimes support the ability to convert their representations to many major timezones, as well as the ability to create a DateTime object in the context of a given timezone.

DateTime objects provide partial numerical behavior:

DateTime objects may be converted to integer, long, or float numbers of days since January 1, 1901, using the standard int, long, and float functions (Compatibility Note: int, long and float return the number of days since 1901 in GMT rather than local machine timezone). DateTime objects also provide access to their value in a float format usable with the python time module, provided that the value of the object falls in the range of the epoch-based time module.

A DateTime object should be considered immutable; all conversion and numeric operations return a new DateTime object rather than modify the current object.

A DateTime object always maintains its value as an absolute UTC time, and is represented in the context of some timezone based on the arguments used to create the object. A DateTime object's methods return values based on the timezone context.

Note that in all cases the local machine timezone is used for representation if no timezone is specified.

DateTimes may be created with from zero to seven arguments.

If a string argument passed to the DateTime constructor cannot be parsed, it will raise DateTime.SyntaxError. Invalid date, time, or timezone components will raise a DateTime.DateTimeError.

The module function Timezones() will return a list of the timezones recognized by the DateTime module. Recognition of timezone names is case-insensitive.


__module__ = __builtin__

Methods

aCommonZ():

Return a string representing the object's value in the format: Mar 1, 1997 1:45 pm US/Eastern

Permission
Always available

aDay():

Return the abbreviated name of the day of the week

Permission
Always available

isCurrentMinute():

Return true if this object represents a date/time that falls within the current minute, in the context of this object's timezone representation

Permission
Always available

millis():

Return the millisecond since the epoch in GMT.

Permission
Always available

aMonth():

Return the abbreviated month name.

Permission
Always available

HTML4():

Return the object in the format used in the HTML4.0 specification, one of the standard forms in ISO8601.

See HTML 4.0 Specification

Dates are output as: YYYY-MM-DDTHH:MM:SSZ T, Z are literal characters. The time is in UTC.

Permission
Always available

month():

Return the month of the object as an integer

Permission
Always available

second():

Return the second

Permission
Always available

ISO():

Return the object in ISO standard format

Dates are output as: YYYY-MM-DD HH:MM:SS

Permission
Always available

year():

Return the calendar year of the object

Permission
Always available

timezone():

Return the timezone in which the object is represented.

Permission
Always available

dow_1():

Return the integer day of the week, where Sunday is 1

Permission
Always available

latestTime():

Return a new DateTime object that represents the latest possible time (in whole seconds) that still falls within the current object's day, in the object's timezone context

Permission
Always available

AMPMMinutes():

Return the time string for an object not showing seconds.

Permission
Always available

DayOfWeek():

Compatibility: see Day

Permission
Always available

isCurrentMonth():

Return true if this object represents a date/time that falls within the current month, in the context of this object's timezone representation

Permission
Always available

PreciseAMPM():

Return the time string for the object.

Permission
Always available

h_24():

Return the 24-hour clock representation of the hour

Permission
Always available

notEqualTo(t):

Compare this DateTime object to another DateTime object OR a floating point number such as that which is returned by the python time module. Returns true if the object represents a date/time not equal to the specified DateTime or time module style time. Revised to give more correct results through comparison of long integer milliseconds.

Permission
Always available

pMonth():

Return the abbreviated (with period) month name.

Permission
Always available

pDay():

Return the abbreviated (with period) name of the day of the week

Permission
Always available

rfc822():

Return the date in RFC 822 format

Permission
Always available

equalTo(t):

Compare this DateTime object to another DateTime object OR a floating point number such as that which is returned by the python time module. Returns true if the object represents a date/time equal to the specified DateTime or time module style time. Revised to give more correct results through comparison of long integer milliseconds.

Permission
Always available

lessThan(t):

Compare this DateTime object to another DateTime object OR a floating point number such as that which is returned by the python time module. Returns true if the object represents a date/time less than the specified DateTime or time module style time. Revised to give more correct results through comparison of long integer milliseconds.

Permission
Always available

TimeMinutes():

Return the time string for an object not showing seconds.

Permission
Always available

isCurrentYear():

Return true if this object represents a date/time that falls within the current year, in the context of this object's timezone representation

Permission
Always available

aCommon():

Return a string representing the object's value in the format: Mar 1, 1997 1:45 pm

Permission
Always available

parts():

Return a tuple containing the calendar year, month, day, hour, minute second and timezone of the object

Permission
Always available

Mon():

Compatibility: see aMonth

Permission
Always available

toZone(z):

Return a DateTime with the value as the current object, represented in the indicated timezone.

Permission
Always available

timeTime():

Return the date/time as a floating-point number in UTC, in the format used by the python time module. Note that it is possible to create date/time values with DateTime that have no meaningful value to the time module.

Permission
Always available

fCommonZ():

Return a string representing the object's value in the format: March 1, 1997 1:45 pm US/Eastern

Permission
Always available

isPast():

Return true if this object represents a date/time earlier than the time of the call

Permission
Always available

fCommon():

Return a string representing the object's value in the format: March 1, 1997 1:45 pm

Permission
Always available

PreciseTime():

Return the time string for the object.

Permission
Always available

isLeapYear():

Return true if the current year (in the context of the object's timezone) is a leap year

Permission
Always available

dd():

Return day as a 2 digit string

Permission
Always available

isCurrentDay():

Return true if this object represents a date/time that falls within the current day, in the context of this object's timezone representation

Permission
Always available

yy():

Return calendar year as a 2 digit string

Permission
Always available

Date():

Return the date string for the object.

Permission
Always available

greaterThan(t):

Compare this DateTime object to another DateTime object OR a floating point number such as that which is returned by the python time module. Returns true if the object represents a date/time greater than the specified DateTime or time module style time. Revised to give more correct results through comparison of long integer milliseconds.

Permission
Always available

isFuture():

Return true if this object represents a date/time later than the time of the call

Permission
Always available

Time():

Return the time string for an object to the nearest second.

Permission
Always available

earliestTime():

Return a new DateTime object that represents the earliest possible time (in whole seconds) that still falls within the current object's day, in the object's timezone context

Permission
Always available

day():

Return the integer day

Permission
Always available

minute():

Return the minute

Permission
Always available

Day_():

Compatibility: see pDay

Permission
Always available

hour():

Return the 24-hour clock representation of the hour

Permission
Always available

ampm():

Return the appropriate time modifier (am or pm)

Permission
Always available

mm():

Return month as a 2 digit string

Permission
Always available

pCommon():

Return a string representing the object's value in the format: Mar. 1, 1997 1:45 pm

Permission
Always available

AMPM():

Return the time string for an object to the nearest second.

Permission
Always available

Day():

Return the full name of the day of the week

Permission
Always available

Month():

Return the full month name

Permission
Always available

isCurrentHour():

Return true if this object represents a date/time that falls within the current hour, in the context of this object's timezone representation

Permission
Always available

lessThanEqualTo(t):

Compare this DateTime object to another DateTime object OR a floating point number such as that which is returned by the python time module. Returns true if the object represents a date/time less than or equal to the specified DateTime or time module style time. Revised to give more correct results through comparison of long integer milliseconds.

Permission
Always available

dayOfYear():

Return the day of the year, in context of the timezone representation of the object

Permission
Always available

greaterThanEqualTo(t):

Compare this DateTime object to another DateTime object OR a floating point number such as that which is returned by the python time module. Returns true if the object represents a date/time greater than or equal to the specified DateTime or time module style time. Revised to give more correct results through comparison of long integer milliseconds.

Permission
Always available

Mon_():

Compatibility: see pMonth

Permission
Always available

h_12():

Return the 12-hour clock representation of the hour

Permission
Always available

pCommonZ():

Return a string representing the object's value in the format: Mar. 1, 1997 1:45 pm US/Eastern

Permission
Always available

dow():

Return the integer day of the week, where Sunday is 0

Permission
Always available

strftime(format):

Return date time string formatted according to format

See Python's time.strftime function.