This version is out of date, covering development from v7.0.0 to v7.5.6. It is maintained here only for inbound reference links from elsewhere. It is no longer actively updated.

Jump to the current version of aTbRef

Tinderbox 7 Icon

date(string)


Operator Type: 

Operator Scope of Action: 

Operator Purpose: 

Operator First Added: 

Operator Altered: 

 Function   [other Function type actions]

 Item   [operators of similar scope]

 Date-time   [other Date-time operators]

 Baseline

 


date(string)

constructs a Date from a quoted string or string expression. Usually, this is not necessary; Tinderbox will coerce the string to a date type automatically. In some contexts though, it may be more convenient or more clear to make the conversion explicit. (See format() and .format() to convert dates into strings).

This operator creates actual Date-type data, which the examples below are actually coercing back into a string Note too that the examples below were output from a system with UK setting, thus using day-month order. For reference, month-day order is actually only used in the USA and the Philippines - the rest of the world uses day-month, though the delimiters used in text can vary (slash, colon, dot, etc.). The action code shown is being exported via ^value()^.

Note that seconds are ignored (from v5 onwards); if provided they are not used and are coerced to '00' instead.

Default: date("24/10/2009") gives 24/10/2009, 12:46; note how the hh:mm current at export get added. The resulting string is the same as you see for a date displayed as a key attribute. The exact format will depend on the users international settings.

Provide a time: date("24/10/2009 01:30:22") gives 24/10/2009, 01:30; the specified time gets used.

Provide a date formatting string:

format(date("24/10/2009 01:30:00"),"*") gives Sat, 24 Oct 2009 01:30:00 +0100

or:

date("24/10/2009 01:30:00").format("*") gives Sat, 24 Oct 2009 01:30:00 +0100

The two methods are equivalent, note also the change of format due to use of a date format string. In the first example above note how the format() operator wraps date() and not vice versa.

An attribute can also provide part of the input:

$EndDate = date($StartDate+"7 days") 

With care this can be extended. In the following, $MyString is "7 days" and $MyNum is 7. The outcome is that $MyDateA/B/C are all set to the same date:

$MyDateA = date($MyDate+"7 days") 

$MyDateB = date($MyDate+$MyString) 

$MyDateC = date($MyDate+($MyNum+" days")) note the extra parentheses are optional but suggested