cms icon indicating copy to clipboard operation
cms copied to clipboard

[6.x] Different date field behaviour

Open marcorieser opened this issue 6 months ago • 6 comments

Bug description

I just noticed that the date field for dated collections behaves differently from a date field for non-dated collections or just a plain date field in the blueprint.

I have a dated collection, and the date field doesn't have time enabled. When creating a new entry, it is saved as 2025-09-26-0657.test.md. I would assume it would save either without a time (2025-09-26.test.md) or set it to midnight (2025-09-26-0000.test.md).

This is especially weird because any other date field on a blueprint uses midnight when time is disabled for the field.

I'm not sure if that is the existing behaviour since ever, but I'd argue that setting just the date on an entry means "today".

How to reproduce

  • Setup a new Statamic v6 site
  • Create a dated collection
  • Ensure the date field is without time enabled
  • Add another date field without time enabled
  • Create an entry

Logs


Environment

Environment
Application Name: handschin & handschin
Laravel Version: 12.31.1
PHP Version: 8.3.26
Composer Version: 2.8.11
Environment: local
Debug Mode: ENABLED
URL: statamic-handschin.test
Maintenance Mode: OFF
Timezone: UTC
Locale: en

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: file
Database: sqlite
Logs: stack / single
Mail: log
Queue: sync
Session: file

Storage
public/storage: NOT LINKED

Livewire
Livewire: v3.6.4

Statamic
Addons: 3
Sites: 1
Stache Watcher: Enabled (auto)
Static Caching: Disabled
Version: 6.0.0-alpha.9 PRO

Statamic Addons
marcorieser/statamic-livewire: dev-statamic-6
marcorieser/statamic-vitals: dev-statamic-6
marcorieser/tailwind-merge-statamic: dev-statamic-6

Installation

Fresh statamic/statamic site via CLI

Additional details

No response

marcorieser avatar Sep 26 '25 07:09 marcorieser

Let's say, I schedule an entry to go live for tomorrow (set it to the date of tomorrow), and I create that post at 10 pm. In the morning, I get up and the entry is not visible because it was scheduled for tomorrow 10 pm (but that was not clear at all).

marcorieser avatar Sep 26 '25 07:09 marcorieser

I have a dated collection, and the date field doesn't have time enabled. When creating a new entry, it is saved as 2025-09-26-0657.test.md. I would assume it would save either without a time (2025-09-26.test.md) or set it to midnight (2025-09-26-0000.test.md).

That's strange... it should save as the UTC equivalent of midnight in your timezone (eg. 2025-09-26-0200.test.md). We'll look into it.

duncanmcclean avatar Oct 08 '25 10:10 duncanmcclean

@duncanmcclean This seems fixed if I manually set the date (can be today) for the dated entry, but if I don't touch that field, it still saves as now (with correct UTC handling). Can you reopen that or should I add another issue?

marcorieser avatar Oct 22 '25 07:10 marcorieser

If you have any existing entries with "bad data" (eg. dates you selected before this bug was fixed), you'll need to re-select them.

duncanmcclean avatar Oct 22 '25 08:10 duncanmcclean

@duncanmcclean no, for new ones.

marcorieser avatar Oct 22 '25 08:10 marcorieser

Oh, I see, we can fix that! 👍

duncanmcclean avatar Oct 22 '25 08:10 duncanmcclean