How to format dates and calculate time differences
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.
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[...].
7 date tools to know
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.
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.
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].
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.
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.
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.
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.
Common searches
date format • format date • date calculation • hh-date.format • str2datetime • date difference • timestamp placeholder • date picker
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article