How to format dates and calculate time differences
Hubhus provides a comprehensive set of tools for working with dates and times in templates, booking forms, and automations.
On this page
Jump to any section using the links below
Hubhus provides a comprehensive set of tools for working with dates and times in templates, booking forms, and automations. This includes system timestamps, localized formatting, parsing, rounding, and date-time input fields with configurable behaviour. This article explains how to use the available placeholders and components to format dates, calculate differences, and configure date-time inputs.
1. System timestamp placeholders
Table of Contents
- 1. System timestamp placeholders
- 2. Parsing dates with @str2datetime
- 3. Language formatting (DK formats)
- 4. Formatting dates using
- 5. Displaying date ranges with
- 6. Calculating time differences with
- 7. Rounding dates (ceil, floor, round)
- 8. Formatting numeric calculations with
- 9. Working with date-time input fields in forms
- Summary
These give you the current date or datetime in Hubhus’ strict database format.
Current datetime (Y-m-d H:i:s):
Current date (Y-m-d):
Use these for automation logic, storing values, or generating consistent timestamps.
2. Parsing dates with @str2datetime
You can convert English text into a strict datetime value using:
Examples:
The output is always in strict format: YYYY-MM-DD HH:MM:SS.
3. Language formatting (DK formats)
Hubhus includes helpers for user-friendly, Danish-formatted output.
Date only:
Date and time:
Time only:
These are ideal for emails sent to customers.
4. Formatting dates using <hh-date.format>
To format any date value:
Hubhus automatically formats the value based on system conventions.
5. Displaying date ranges with <hh-date.interval>
Use this component to present a start and end time cleanly:
Customers will see a readable “from–to” interval.
6. Calculating time differences with <hh-date.diff>
To compute differences between two dates:
Supported units include:
seconds
minutes
hours
days
Use this for delays, reminders, or workflow timing logic.
7. Rounding dates (ceil, floor, round)
Hubhus can align datetimes to minute-based intervals. Examples:
Round up:
Round down:
Round to nearest:
Useful for working with booking-slot intervals (for example, 5-, 10-, or 15-minute increments).
8. Formatting numeric calculations with <hh-number.format>
If you output numeric durations or other calculated values, you can control decimal formatting:
This is optional but helpful when presenting numeric values in emails.
9. Working with date-time input fields in forms
Hubhus provides a dedicated input type for selecting both date and time:
This creates a combined date/time picker with support for multiple configuration attributes.
Supported data-* attributes
| Attribute | Description | Typical values |
|---|---|---|
data-format | Display format for date/time | yyyy-mm-dd hh:ii |
data-minute-step | Minute increments | 1, 5, 10, 15 |
data-start-date | Earliest selectable value | Date string |
data-end-date | Latest selectable value | Date string |
data-min-view | Lowest view (hour/day) | 0 or "hour" |
data-max-view | Highest view (year/month) | 4 or "year" |
data-week-start | First day of week | 0 or 1 |
data-autoclose | Close on selection | true/false |
data-today-btn | Show "Today" button | true/false |
data-force-parse | Parse typed input | true/false |
Common configuration recipes
15-minute steps, Monday as week start:
Allow only next 30 days:
Date-only input (no time selection):
Show Today button and autoclose:
Important notes
Ensure that
data-formatmatches any prefilled valueKeep minute steps consistent with your booking intervals
Use strict formats (Y-m-d H:i:s) when working with automations
Summary
Hubhus offers a complete set of tools for handling dates and times:
System timestamps
English-to-datetime parsing
Localized DK formatting
Date interval display
Time difference calculation
Rounding to specific intervals
Configurable date-time input fields
Optional numeric formatting
These tools make it easy to work with dates in emails, automations, booking flows, and internal templates.
? Common searches
web form • form setup • booking form • form builder
? Also known as
web form • input form • data capture
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