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

Jump to the current version of aTbRef

TinderboxSix Icon

Checking and setting Time correctly in Date data

Tinderbox Date-type data always includes a time element, even if not explicitly set by the user. If not supplied when first set, the current OS system clock time is used for the item element - even if the date element is for a different day. Seconds are not set, or are always considered to be 00. The time element of dates makes some date comparisons work in unexpected ways.

Methods to see/check a Date's time:

To set or change the time element of a date:

When working with date designators, and explicit (24-hour clock) time can be added stated. At 14:23 on 28 November 2012:

date("today") gives 28 November 2012 14:23

date("today - 2 days") gives 26 November 2012 14:23


date("today 23:59") gives 28 November 2012 23:59

date("today - 2 days 08:00") gives 26 November 2012 08:00

If wanting to use greater than or less than date comparisons, it can be helpful to explicitly set a time value like 00:00 or 23:59 if wanting to test for a full day midnight-to-midnight.

Another context where (re-)setting a fixed time can be useful is with timelines and historical dates, for instance setting all times to 08:00 or some other common time, if only to avoid effectively random times set automatically when creating dates by supplying on the date and no time. Tidying up existing dates is not hard. Make an agent to find the notes needing tidying, and that add an action like:

$StartDate = time($StartDate,08,00) 

Note that as the code force-changes just the hours/minutes the actual date cannot be affected. For existing data, you can run the above and delete the agent. However, if you have processes creating new events it is worth checking date designator offsets - like the examples above - also use an explicit time before you delete or turn off the agent.

A Tinderbox Reference File : Actions & Rules : Checking and setting Time correctly in Date data