Skip to content

Localized date field returns wrong type #12334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
MarvinVrdoljak opened this issue May 7, 2025 · 2 comments · Fixed by #12354
Closed

Localized date field returns wrong type #12334

MarvinVrdoljak opened this issue May 7, 2025 · 2 comments · Fixed by #12354
Assignees

Comments

@MarvinVrdoljak
Copy link

Describe the Bug

I’ve encountered a bug with localized date fields. Instead of returning a string - they return a Date object. This behavior causes a runtime error in my project, where a string is required.

Link to the code that reproduces this issue

https://github.com/MarvinVrdoljak/payload-bug-report-2

Reproduction Steps

The Pages collection is located at:
/home/marvin/websites/payload-bug-report-2/src/collections/Pages/index.ts
It contains two new date fields: one localized, one not.

In the frontend rendering file at:
/home/marvin/websites/payload-bug-report-2/src/app/(frontend)/[slug]/page.tsx
you’ll find a console.log showing the incorrect output of the localized field.

Image

Which area(s) are affected? (Select all that apply)

area: core

Environment Info

Binaries:
  Node: 22.14.0
  npm: 10.9.2
  Yarn: N/A
  pnpm: 10.10.0
Relevant Packages:
  payload: 3.33.0
  next: 15.3.0
  @payloadcms/db-mongodb: 3.33.0
  @payloadcms/email-nodemailer: 3.33.0
  @payloadcms/graphql: 3.33.0
  @payloadcms/live-preview: 3.33.0
  @payloadcms/live-preview-react: 3.33.0
  @payloadcms/next/utilities: 3.33.0
  @payloadcms/payload-cloud: 3.33.0
  @payloadcms/plugin-form-builder: 3.33.0
  @payloadcms/plugin-nested-docs: 3.33.0
  @payloadcms/plugin-redirects: 3.33.0
  @payloadcms/plugin-search: 3.33.0
  @payloadcms/plugin-seo: 3.33.0
  @payloadcms/richtext-lexical: 3.33.0
  @payloadcms/translations: 3.33.0
  @payloadcms/ui/shared: 3.33.0
  react: 19.1.0
  react-dom: 19.1.0
Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP Tue Nov 5 00:21:55 UTC 2024
  Available memory (MB): 15672
  Available CPU cores: 22
@MarvinVrdoljak MarvinVrdoljak added status: needs-triage Possible bug which hasn't been reproduced yet validate-reproduction Auto-added tag on create to tell bot to check recreation URL, removed after check. labels May 7, 2025
@github-actions github-actions bot removed the validate-reproduction Auto-added tag on create to tell bot to check recreation URL, removed after check. label May 7, 2025
@paulpopus paulpopus self-assigned this May 8, 2025
@github-actions github-actions bot removed the status: needs-triage Possible bug which hasn't been reproduced yet label May 8, 2025
@paulpopus paulpopus added the status: verified If an issue has been reproduced label May 8, 2025
paulpopus added a commit that referenced this issue May 11, 2025
…ad of strings (#12354)

Fixes #12334

We weren't passing locale through to the Date transformer function so
localized dates were being read as objects instead of strings.
@github-actions github-actions bot removed the status: verified If an issue has been reproduced label May 11, 2025
kendelljoseph pushed a commit that referenced this issue May 15, 2025
…ad of strings (#12354)

Fixes #12334

We weren't passing locale through to the Date transformer function so
localized dates were being read as objects instead of strings.
Copy link
Contributor

🚀 This is included in version v3.38.0

kendelljoseph pushed a commit that referenced this issue May 19, 2025
…ad of strings (#12354)

Fixes #12334

We weren't passing locale through to the Date transformer function so
localized dates were being read as objects instead of strings.
Copy link
Contributor

This issue has been automatically locked.
Please open a new issue if this issue persists with any additional detail.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 23, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants