Skip to content
Tutorials Center
My learning

Topics

Lesson 17 of 36 ยท Filters, Paths and Formatting

Formatter: Working with Dates, Times and Time Zones

Convert date formats, add or subtract time, compare dates and handle time zones and daylight saving in Zaps, with token tables and runnable Python stand-ins for every transform.

Dates are the most error-prone data in automation. Apps send "03/04/2026" (March 4 or April 3?), "2026-03-04T09:30:00Z", or "4 March 2026". Time zones and daylight saving make arithmetic subtle. Zapier's Formatter has a Date / Time transform group to convert, shift and compare dates; this lesson explains the concepts and options.

Zapier cannot run on this site. The editor's option labels can differ; we describe the ideas. The Python blocks are labelled stand-ins: they do the same conversions with Python's datetime so you can test your format strings.

Formats and tokens

A date format is a pattern made of tokens. Zapier's Formatter uses a common token style (like YYYY-MM-DD). Typical tokens:

Token Meaning Example
YYYY four-digit year 2026
MM month number 03
DD day of month 04
HH hour (24h) 09
mm minutes 30
ss seconds 00
MMMM month name March

Check the help text in the Formatter step for the exact tokens; some use different letters (for example %Y style in programming languages). The important idea: you give the input format (how the text currently looks) and the output format (how you want it).

ISO 8601: the safe format

Whenever you can, store and pass dates as ISO 8601: 2026-03-04 for dates and 2026-03-04T09:30:00Z (or with an offset like +01:00) for date-times. It sorts alphabetically in time order, is unambiguous (year first), and most apps accept it.

Converting formats: a stand-in

In Python the tokens differ (%Y-%m-%d), but the process is identical: parse with the input format, then format with the output format.

Python Stand-in: change a date's format

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The first two inputs look similar but give different dates, which is why you must know the source's convention rather than guess.

Adding and subtracting time

A common need: "due date is 14 days after the order", "send a reminder 1 day before the event", "last day of the month". Formatter can add or subtract units (days, hours, months). Remember that adding months is not a fixed number of days.

Python Stand-in: add days, hours and months

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

January 31 plus one month has no "February 31", so the result is clamped to the end of February. Whatever your tool does, test the edge cases with end-of-month dates.

Time zones

A date-time without a zone is ambiguous. Rules that keep you safe:

  1. Know the source time zone (the app may send UTC, or the user's local time with no label).
  2. Convert to UTC for storage and comparisons, then to the viewer's zone for display.
  3. Use named zones such as Europe/Berlin rather than fixed offsets, because offsets change with daylight saving time.
  4. For schedule triggers, choose the time zone explicitly so "9:00" means what you think.
Python Stand-in: offsets change with daylight saving

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

A real tool uses a time zone database, so you only say Europe/Berlin and it applies the right offset for the date.

Comparing dates

Filters can compare dates (is after, is before) when both sides are in a comparable format and zone. To test "is this order older than 30 days", compute a cutoff date with Formatter ("today minus 30 days") and compare. To compare in a Formatter step, convert both dates to a timestamp (a number of seconds) and subtract. Comparing formatted strings only works for ISO format.

Python Stand-in: is a record older than 30 days?

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Common date mistakes

  • Day/month swapped (04/03).
  • Naive date-times treated as UTC (or the reverse).
  • Using fixed offsets across daylight saving changes.
  • Comparing text dates that are not ISO formatted.
  • Forgetting that "end of day" means 23:59:59 in a specific zone.
  • Weekdays and week numbers differing by country (week starts on Sunday or Monday).

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Why prefer ISO 8601 dates such as 2026-03-04?

    ISO puts the year first, so there is no day/month confusion and sorting works.
  2. 2. What is the result of adding one month to Jan 31 in most tools?

    February has no 31st; tools clamp or roll over, so test end-of-month cases.
  3. 3. Why use a named zone like Europe/Berlin instead of +01:00?

    A fixed offset is wrong for half the year in zones with daylight saving.
  4. 4. When must you know the input format?

    Without the input format, day-first and month-first dates look identical.

Summary

  • Formatter converts date formats using input and output tokens; prefer ISO 8601.
  • Adding months and end-of-month dates need testing.
  • Store and compare in UTC; convert to named zones for display and scheduling.
  • Compare dates only after unifying format and zone, or use timestamps.

Next: Looping, Lookups and Digests