date

Top  Previous  Next

date

dt=new("date")

 

The date object provides date-oriented functionality, including date parsing and formatting.  When the date object is created, the datetime property is set to the current date and time.  A datetime value is a numeric Julian number, indicating the number of days since January 1, 4713 BC, plus time expressed as a fraction of a day.  Methods are provided for parsing a text date into a datetime value, to format a datetime value into a human-readable value, and to calculate elapse time between two datetime values in different increments.

 

Properties

 

d is a read-only property that provides the day.

datetime is the date and time value upon which all methods work.  The datetime value is initially set to the date and time at the moment the object is created.  It can be updated to the current date and time with the update() method, or set to a value via the parsedate() function or setdate() function.

hr is a read-only property that provides the hour (using a 24 hour clock).

m is a read-only property that provides the month.

mn is a read-only property that provides the minute.

se is a read-only property that provides the second.

utcoffset provides the offset from Universal Time for the local time zone.  The value is provided as a fraction of a day, so it can be added or subtracted from datetime without any conversion.

y is a read-only property that provides the year.

 

Methods

 

days([enddatetime]) returns the number of days, with a fractional amount, between the current date and time and datetime, or the supplied date and time (such as the datetime value of another date object).

format$([fmt$]) returns the formatted date and time.  If no format is supplied, or it is null or "utc", the date is returned in UTC format in adjusted by the utcoffset property.  For example: Fri, 7 Aug 2009 23:17:04 +0000. If fmt$ is "local", then the format is the same, but reported for the local time zone.  For example: Fri, 7 Aug 2009 16:17:04 -0700.  If fmt$ is "ymd", then a 14-byte string is returned in the format yyyymmddhhmmss.  If fmt$ is "iso" or "isodtm", a date (yyyymmdd) or date-time (yyyymmddThhmmssZ) format is returned, using UTC time rather than local time.

Additional formats are custom, using mapping characters that are replaced with appropriate date/time components.  The characters are:

am or pm
AM or PM
YYYY or YY (4- or 2-digit year)
MMMM, MMM or MM (month name, abbreviation, or number)
DDDD, DDD, or DD (day name, abbreviation, or number)
HH (24 hour clock)
hh (12 hour clock)
mm
ss
tzc, tz (timezone offset from UTC, in +/-HH:mm or +/-HHmm format)

 

Other characters represent themselves.  "MM/DD/YYYY" would return a typical US date.  DD/MM/YYYY would return a typical Canadian date.

fromutcseconds(utc-seconds) sets the instance's date/time value based on the utc-seconds value supplied, which is a common operating and internet time format of the number of seconds since Jan 1, 1970 in UTC (0000 timezone) time.

hours([enddatetime]) returns the number of hours between the current date and time and datetime, or the supplied date and time.

minutes([enddatetime]) returns the number of minutes between the current date and time and datetime or the supplied date and time.

parsedate(datestr$[,fmt$]) parses a human readable date using fmt$ for parsing rules, sets datetime, and returns datetime.  If not supplied, the default format is "utc".  The parsing rules are "utc" for UTC format, "ymd" for yyyymmddhhmmss format (if all digits) or "mdy" or "dmy" or "ymd" for delimited dates, such as 12/31/2009 or 31/12/2009.

seconds([enddatetime]) returns the number of seconds between the current date and time and datetime, or the supplied date and time.

setdate(year, month, day [,hours [,minutes [,seconds]]]) sets the date and time according to the arguments provided, and returns datetime.  Only year, month, and day arguments are required.

update() updates datetime to the current date and time, and returns datetime.