As you’ll note I’ve updated my notes on the Interval attribute data type which should clarify the syntax.
If you type/paste 01:10
value into an Interval attribute in Get Info or Displayed Attributes, e.g. your $Timestamp attribute, you are setting a valid interval of 1 minute and 10 seconds. To set the same via action code use:
$MyInterval = "01:10";
For nuance of using day or hour elements in the interval, see my article linked at the start of the post.
To advance a date(/time) value (i.e. in a Date date type attribute or variable) you add the Interval without _ a date() wrapper. this is because Tinderbox knows Interval data is already (under the hood) a duration in milliseconds that it can use with a Date. Thus:
$StartDate = $StartDate + $Timestamp;
Or in newer syntax:
$StartDate += $Timestamp;
To move time backwards either subtract a positive duration
$StartDate -= $Timestamp;
or add using a negative interval:
var:interval vTime="-03:00:00";
$StartDate += vTime;
// sets $StartDate 3 hours earlier
Depending on your degree of automation, the latter may prove more useful allowing the same code to correctly handle additions and subtraction of time. In the above case vTime might be set using value generated by some other code and might be a positive or negative duration.
Leaving aside the already reported issue of working with as-yet undefined Date attributes (so for now, always set a date—any sensible date!—before use), changing durations at whole day or month/year scope should be done with date arithmetic. To add 4 days to $StartDate:
$StartDate = date($StartDate+"4 days");
or
$StartDate += "4 days";
There are some subtleties here as regards usage, depending on where the data is to be passed. A common ‘quick’ test is to run a stamp on a Displayed Attributes value and show the value in $Text. But, consider using a another Date attribute instead:
// assume $Start date is 15 Aug 2022 at 00:00:00
$Text = $StartDate+"1 month"; // gives '1663196400'
$TestDate = $StartDate+"1 month"; // gives'15 Sep 2022 at 00:00:00'
$Text = date($StartDate+"1 month"); // gives '15 Sep 2022 at 00:00:00'
$TestDate = date($StartDate+"1 month"); // gives'15 Sep 2022 at 00:00:00'
Thus use of $Text (or a String attribute such as my string) and silent auto-coercion of data type may lead the user astray when testing. In all four cases above the correct date resulted but in one case the lack of a date()
wrapper caused the raw millisecond count to show and thus suggest an error where none had really occurred.