Skip to content

feat(notifications): allow configurable date/time format via env - #5578

Draft
davidpru wants to merge 1 commit into
Dokploy:canaryfrom
davidpru:feat/notifications-date-time-format
Draft

davidpru wants to merge 1 commit into
Dokploy:canaryfrom
davidpru:feat/notifications-date-time-format

Conversation

@davidpru

@davidpru davidpru commented Oct 4, 2026

Copy link
Copy Markdown

What is this PR about?

Notification messages (Telegram, Slack, Discord, Mattermost, Lark, email, etc.) format dates with format(date, "PP") / format(date, "pp") from date-fns without a locale, so times always render in 12-hour US style (e.g. 1:49:41 PM). Users outside the US have no way to get 24-hour time or a local date format.

This PR adds two optional environment variables:

Variable Default Example
NOTIFICATIONS_DATE_FORMAT PP dd/MM/yyyy
NOTIFICATIONS_TIME_FORMAT pp HH:mm:ss (24-hour)

How

  • New helpers in utils/notifications/utils.ts: formatNotificationDate, formatNotificationTime, formatNotificationDateTime.
  • All format(date, "PP" | "pp" | "PP pp") calls in the notification senders now use these helpers (build-error, build-success, database-backup, docker-cleanup, dokploy-backup, dokploy-restart, volume-backup).
  • No behavior change by default: without the env vars the output is identical to today.
  • An invalid pattern falls back to the default instead of throwing, so a typo can't break notifications.

Usage

docker service update \
  --env-add NOTIFICATIONS_TIME_FORMAT=HH:mm:ss \
  --env-add NOTIFICATIONS_DATE_FORMAT=dd/MM/yyyy \
  dokploy

Happy to move this to a setting in the UI instead if you prefer that approach.

Checklist

Before submitting this PR, please make sure that:

  • You created a dedicated branch based on the canary branch.
  • You have read the suggestions in the CONTRIBUTING.md file https://github.com/Dokploy/dokploy/blob/canary/CONTRIBUTING.md#pull-request
  • You have tested this PR in your local instance. If you have not tested it yet, please do so before submitting. This helps avoid wasting maintainers' time reviewing code that has not been verified by you.

Opened as draft until it's tested on a local instance. biome check passes on the changed files.

Issues related (if applicable)

N/A

Screenshots (if applicable)

N/A

Notification messages format dates with date-fns `format(date, "PP")` /
`format(date, "pp")` without a locale, so times are always rendered in
12-hour US style (e.g. "1:49:41 PM"), regardless of the server locale.

Add `formatNotificationDate`, `formatNotificationTime` and
`formatNotificationDateTime` helpers that read two optional env vars:

- NOTIFICATIONS_DATE_FORMAT (default: "PP")
- NOTIFICATIONS_TIME_FORMAT (default: "pp")

Defaults keep the current output unchanged. Invalid patterns fall back to
the defaults instead of breaking the notification.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant