format-date

The format-date operation converts a given date string into a specified format. This is useful when normalizing dates for APIs, reports, or user-facing outputs.

How it works

  • Input – the original date as a string (e.g. 2024-02-21 15:30:00).
  • Format pattern – the desired format string, based on the DateTime formatting standard.
  • Result – the date reformatted according to the pattern. If the input cannot be parsed as a valid date, the original value is returned unchanged.

Examples

InputFormat PatternOutput
2024-02-21d.m.Y21.02.2024
2024-02-21 15:30:00Y-m-d H:i2024-02-21 15:30
invalid dated.m.Yinvalid date

Common Format Patterns

  • Y-m-d → 2024-02-21 (ISO format)
  • d.m.Y → 21.02.2024 (European style)
  • m/d/Y → 02/21/2024 (US style)
  • Y-m-d H:i:s → 2024-02-21 15:30:00 (full timestamp)
  • l, j F Y → Wednesday, 21 February 2024 (long text form)

Usage in PalDock

Use format-date when you need to:

  • Convert system-generated dates into the format required by an external API.
  • Display user-friendly date formats in outputs.
  • Standardize dates for reporting and exports.
  • Strip time information (e.g. from Y-m-d H:i:s to Y-m-d).

⚠️ Always put the prefix “@” before the date format.

Best Practices

  • Always use clear and unambiguous formats when passing dates between systems.
  • Be mindful of time zones – format-date only reformats the string, it does not adjust the timezone unless combined with other operations.
  • Validate date strings before formatting to avoid passing invalid data.
  • Stick to ISO 8601 (Y-m-d H:i:s) for machine-to-machine integrations, unless the external system specifies otherwise.

References

https://www.php.net/manual/en/datetime.format.php

Related articles

Modify Field > combine
Modify Field > urldecode
Modify Field > urlencode
Modify Field > load-from-lead
Modify Field > regex-replace
Modify Field > from-base64
Modify Field > to-base64
Modify Field > modify-date
Modify Field > do-not-send
Modify Field > first-regex-match

Insights that
helps you grow