Skip to content

fix(server): render storage template date/time tokens in UTC (#24350)#26917

Merged
danieldietzler merged 4 commits intoimmich-app:mainfrom
migpovrap:storageTemplateUTC
Apr 14, 2026
Merged

fix(server): render storage template date/time tokens in UTC (#24350)#26917
danieldietzler merged 4 commits intoimmich-app:mainfrom
migpovrap:storageTemplateUTC

Conversation

@migpovrap
Copy link
Copy Markdown
Contributor

@migpovrap migpovrap commented Mar 14, 2026

Description

Storage template dates and time were previously rendered using a local server system timezone context, which could produce non-chronological filenames when assets were taken across time zones for example Berlin to London travel like the example given on the issue. This pr changes the behavior so it always renders storage-template standard by using UTC. As asked by the maintainers on the discord Storage Template dates/times not adjusted for timezone it can be easely changed to different default time zone.

Fixes #24350

How Has This Been Tested?

  • Update existing unit tests to use UTC and not an hard coded local time zone.
  • Add new tests that verifies that assets get the correct chronological filename ordering, it is preserverd even if the images were taken in different time zones.
    • Asset A: 2025-12-02T14:00:00.000Z (Berlin metadata)
    • Asset A: 2025-12-02T14:00:00.000Z (Berlin metadata)
    • Storage Template: {{y}}{{MM}}{{dd}}_{{HH}}{{mm}}{{ss}}/{{filename}}
    • Confirms chronological filename ordering is preserved across time zones.

Screenshots (if appropriate)

Checklist:

  • I have carefully read CONTRIBUTING.md
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if applicable
  • I have no unrelated changes in the PR.
  • I have confirmed that any new dependencies are strictly necessary.
  • I have written tests for new code (if applicable)
  • I have followed naming conventions/patterns in the surrounding code
  • All code in src/services/ uses repositories implementations for database calls, filesystem operations, etc.
  • All code in src/repositories/ is pretty basic/simple and does not have any immich specific logic (that belongs in src/services/)

Please describe to which degree, if any, an LLM was used in creating this pull request.

Github Copilot was used to have an overall understading of the codebase and to explain how the tests were made. Chatgpt was used to correct my grammer on the text of this PR.
...

@immich-push-o-matic immich-push-o-matic Bot added documentation Improvements or additions to documentation 🗄️server labels Mar 14, 2026
@mmomjian
Copy link
Copy Markdown
Collaborator

it can be easely changed to different default time zone.

can you explain how this is implemented for the end user?

@migpovrap
Copy link
Copy Markdown
Contributor Author

I now see that this phrase is a bit confusing. In my solution, based on what was discussed in the Immich Discord "Storage Template dates/times not adjusted for timezone", there is currently no way for the end user to change this behavior. I was referring to what one of the maintainers mentioned that this PR could be discussed and we could decide to switch to another time zone if needed.

@mmomjian
Copy link
Copy Markdown
Collaborator

Got it. As I mentioned on the discord, I am personally not in favor of this change not being configurable. Additionally, unless it’s configurable with the default option being the current behavior, this would probably be a breaking change and have to wait for immich v3.

@mmomjian
Copy link
Copy Markdown
Collaborator

I think an additional solution to explore is to provide the timezone as a storage template flag. I think applying UTC to all assets as a blanket policy is too restrictive.

@migpovrap
Copy link
Copy Markdown
Contributor Author

migpovrap commented Mar 15, 2026

I fully understand the concern about it not being configurable. If this is the prefereble way to do it am happy to update my pr to implemment it. Also I did it in this way using UTC because it seemed like the simplest deterministic approach, and it was suggested on the discord.
In alternatively and as one of the other mainatiners said in the discord, since this would change the current behavior, it might make sense to wait for v3 and merge it there since it is a breaking change.
Let me know which direction you’d prefer.

@migpovrap
Copy link
Copy Markdown
Contributor Author

Just bumping this thread since v3 is approaching, I wanted to check how we should proceed with this PR, or implementing the suggested configurable timezone solution for this PR, or hold off for now. Happy to adapt the implementation based on the preferred direction.

@danieldietzler
Copy link
Copy Markdown
Member

Hey, sorry for the delay. We wouldn't want completely customizable time zones at the moment, ideally more options for the storage template will be possible when workflows and plugins are released and went through a couple of iterations.
However, a fixed time zone definitely seems better and we'd like that.

Instead of using UTC, would you be able to change it to always use the server's TZ?

@migpovrap
Copy link
Copy Markdown
Contributor Author

Instead of using UTC, would you be able to change it to always use the server's TZ?

Hey, no worries! Working on it!

Comment thread server/src/services/storage-template.service.ts Outdated
Copy link
Copy Markdown
Member

@danieldietzler danieldietzler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! :)

Comment thread docs/docs/partials/_storage-template.md Outdated
@migpovrap migpovrap force-pushed the storageTemplateUTC branch from a8a2401 to 3c8b010 Compare April 10, 2026 19:21
@migpovrap
Copy link
Copy Markdown
Contributor Author

Hey @danieldietzler, thanks for the review! I have already pushed the small change to the docs you asked. Let me know if everything looks good, or if you need anything else from my end!

@danieldietzler
Copy link
Copy Markdown
Member

Yep, I saw. We were just waiting with merging PRs while some patch releases went out :)

@danieldietzler danieldietzler merged commit e4e2f58 into immich-app:main Apr 14, 2026
48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog:enhancement documentation Improvements or additions to documentation 🗄️server

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Storage Template dates/times not adjusted for timezone

4 participants