Hubhus
ToolsAgent loginSubmit a ticket
All articles

Campaigns & Lead Management / Templates

How to format dates and calculate time differences

Published 28. sep. 2026, 16.03

TL;DR

System timestamps: %timestamp% (Y-m-d H:i:s), %timestamp_date% (Y-m-d). Parse text: @str2datetime[now] , @str2datetime[tomorrow 14:00] . Format: <hh-date.format value="..." format="dd/MM/yyyy" /> . Date range: <hh-date.interval> . Difference: <hh-date.diff> . Round: <hh-date.ceil/floor/round> . DK format: @dateformat_da[...] .

Hubhus provides built-in date tools for use in templates, booking forms, and automations - formatting, parsing, calculating differences, rounding, and working with date-time input fields.

7 date tools to know

  1. System timestamp placeholders. %timestamp% → current datetime (Y-m-d H:i:s). %timestamp_date% → current date (Y-m-d). Use for automation logic, storing timestamps in fields, or consistent datetime generation.
  2. Parsing dates with @str2datetime. Convert English text into strict datetime: @str2datetime[now], @str2datetime[tomorrow 14:00], @str2datetime[first day of next month], @str2datetime[+7 days]. Useful for computing relative dates in automations and field values.
  3. Formatting dates with hh-date.format. <hh-date.format value="%lead_event_start%" format="dd/MM/yyyy" /> - display a stored date in a human-readable format. Common formats: dd/MM/yyyy, yyyy-MM-dd, dd. MMMM yyyy, HH:mm. Use DK-specific formatting with @dateformat_da[date].
  4. Date ranges with hh-date.interval. <hh-date.interval from="..." to="..." /> - display a formatted date range (e.g. "Mon 5. May - Fri 9. May"). Useful in booking confirmations and event summaries.
  5. Calculating differences with hh-date.diff. <hh-date.diff from="..." to="..." unit="days" /> - calculate the difference between two dates. Units: days, hours, minutes. Use in confirmation emails ("Your appointment is in 3 days") or automation conditions.
  6. Rounding dates (ceil/floor/round). <hh-date.ceil value="..." unit="hour" /> - round up/down/nearest to hour, day, week, month. ceil = round up, floor = round down, round = nearest. Useful for slot calculations and time window logic.
  7. Date-time input fields in forms. Configure date/time picker inputs with data-* attributes: data-datepicker (enable picker), data-min-date/data-max-date (restrict range), data-default-value (pre-fill). Example: pre-fill with computed date using <hh-date.calculate> in a hidden input.
Read more

Date-time input field - syntax and attributes

Base syntax:

@input[date-time-strict; id='my-datetime'; data-minute-step='15']

Supported data-* attributes:

  • data-format - display format for the picker (e.g. yyyy-mm-dd hh:ii)
  • data-minute-step - minute increment steps: 1, 5, 10, or 15
  • data-start-date - earliest selectable date (date string)
  • data-end-date - latest selectable date (date string)
  • data-min-view - lowest zoom level: 0 (hours) or 1 (days)
  • data-max-view - highest zoom level: 3 (months) or 4 (years)
  • data-week-start - first day of week: 0 (Sunday) or 1 (Monday)
  • data-autoclose - close picker after selection: true/false
  • data-today-btn - show "Today" shortcut button: true/false
  • data-force-parse - parse typed input: true/false

Configuration recipes

15-minute steps with Monday as week start:

@input[date-time-strict; data-minute-step='15'; data-week-start='1']

Allow only the next 30 days:

@input[date-time-strict; data-start-date='%now%'; data-end-date='%now_plus_30d%']

Date-only input (hide time selection):

@input[date-time-strict; data-min-view='1'; data-max-view='1']

Show Today button and auto-close on selection:

@input[date-time-strict; data-today-btn='true'; data-autoclose='true']

DK date formatting helpers

For user-friendly Danish output in emails and templates:

@date_dk[%event_start_date_db%]         <!-- date only -->
@datetime_dk[%event_start_datetime_db%] <!-- date and time -->
@time_dk[%event_start_datetime_db%]     <!-- time only -->

Important notes for input fields:

  • Ensure data-format matches the format of any pre-filled value
  • Keep minute steps consistent with your booking slot intervals
  • Always use strict format (Y-m-d H:i:s) when storing to fields used in automations
date
format
time
calculation
Didn't find the answer? Submit a ticket and we'll get back to you as soon as possible.