Skip to main content

Date and time operations

Learn how to convert date and time in Tines

Written by Jamie Gaynor

What timezone does DATE("now") function return?

DATE("now") will return a UTC time.

Read about the DATE function in our docs.

You can find an example of DATE function uses in the story library

How can I convert timezones in Tines?

There are two examples in the action below,

  • UTC to PST (28800 seconds difference)

  • UTC to PDT (25200 seconds difference)

You can copy/paste the below code into your story board:

{"standardLibVersion":"20","actionRuntimeVersion":"4","agents":[{"disabled":false,"name":"Timezone","description":null,"options":"{\"mode\":\"message_only\",\"PST\":\"<<DATE(\\\"now\\\", \\\"%s\\\") |> MINUS(%, 28800) |> DATE(%, \\\"%Y-%m-%dT%H:%M:%S\\\")>>\",\"PDT\":\"<<DATE(\\\"now\\\", \\\"%s\\\") |> MINUS(%, 25200) |> DATE(%, \\\"%Y-%m-%dT%H:%M:%S\\\")>>\"}","position":{"x":705,"y":780},"type":"eventTransformation","timeSavedUnit":"minutes","timeSavedValue":0,"monitorAllEvents":false,"monitorFailures":false,"monitorNoEventsEmitted":null,"spotlightTemplate":null,"spotlightWriters":[],"form":null,"cardIconName":null,"cardIconColor":null,"createdFromTemplateGuid":null,"createdFromTemplateVersion":null}],"links":[],"diagramNotes":[]}

Converting time into UNIX or epoch time

To convert time into UNIX time, use the function DATE("now", "%s")

Calculate the difference between two dates

Option 1: Using formulas

You can calculate time differences using the DATE_TO_UNIX formula:

=DATE_TO_UNIX("2026-04-15") - DATE_TO_UNIX("2026-01-01")


This gives you the difference in seconds. Then divide:
÷ 60 → minutes
÷ 3600 → hours

÷ 86400 → days

Example in an event transform (automatic mode):

{ 
"diff_in_days": "=DIVIDE(MINUS(DATE_TO_UNIX(date_two),
DATE_TO_UNIX(date_one)), 86400)"
}

Option 2: Using a run script action (python)

If you need more precision or complex date math, a python script is very flexible:

from datetime import datetime
date1 = datetime.strptime("{{ date_one }}", "%Y-%m-%d")
date2 = datetime.strptime("{{ date_two }}", "%Y-%m-%d")
diff = (date2 - date1).daysprint(diff)

To learn more about the date function, see here

You can find an example of DATE function in the story library

Did this answer your question?