getkirby / kirby

Kirby's core application folder
https://getkirby.com
Other
1.27k stars 167 forks source link

Time in date field with default: now is always 00:00 #3106

Closed sebastiangreger closed 2 years ago

sebastiangreger commented 3 years ago

Describe the bug
When creating a new page in the Panel, a date field with default set to now always shows 00:00 as time.

To Reproduce
Steps to reproduce the behavior:

  1. Install a fresh Starterkit and log in to the panel
  2. Click "Add" for Notes to create a new note
  3. See error: the time in the date field shows 00:00 (despite default set to now in the note.yml blueprint)

The error also persists when altering the blueprint as follows:

date:
  type: date
  time:
    step: 1
    display: HH:mm
    default: now
  default: now

Expected behavior
A time field with time: true and default: now would use the current time, either by default or at least when the time value is also set to default: now.

Kirby Version
3.5.1

Console output
No console output.

Desktop:

distantnative commented 3 years ago

Just on my phone, so apologies that I can't check myself right now. But I think it's because your blueprint defines the step as 1 day and everything gets rounded to the nearest day therefore.

moevbiz commented 3 years ago

I'm having the same issue with every date field, without having set step at all.

date:
  type: date
  time: true
  default: today
  # same with default: now
  display: DD.MM.YYYY

See also this thread in the forum: https://forum.getkirby.com/t/panel-time-defaults-to-00-00/20896?u=bruno

afbora commented 3 years ago

But I think it's because your blueprint defines the step as 1 day and everything gets rounded to the nearest day therefore.

@distantnative But step is set for time prop. Shouldn't it be 1 minute?

distantnative commented 3 years ago

That happens when I read on the phone 🙈 I would imagine all of it is related to the step mechanism but I also agree if it's date and time the default step should be based on minute, if only date then on day

moevbiz commented 3 years ago

so what's the definite solution to store date & time with a correct time default? it's always showing 00:00, no matter what I do...

MaluNoPeleke commented 3 years ago

Would also be nice to have a time picker in the popup as well.

distantnative commented 3 years ago

@MaluNoPeleke could you please create this as an idea over at feedback.getkirby.com? Thanks?

MaluNoPeleke commented 3 years ago

I guess I found one: https://kirby.nolt.io/304

isaactopo commented 3 years ago

It would be very nice to solve this as it is a problem for RSS automations with Mailchimp, thanks! <3

teichsta commented 3 years ago

same, here would be very interested in a fix @distantnative.

MaluNoPeleke commented 3 years ago

Could this be part of Kirby 3.6.0 @afbora @bastianallgeier?

isaactopo commented 2 years ago

Not solved on 3.6, right?

distantnative commented 2 years ago

✅ will be fixed in 3.6.2

vivaneo commented 2 years ago

Hello,

in 3.6.6 it is not corrected. Do not forget us :)

sebastiangreger commented 2 years ago

I have a blueprint using

date:
  type: date
  time:
    step: 1
    display: HH:mm
  default: now

and this has worked fine ever since 3.6.2 – it sets both date and time to the current moment, as expected.

@vivaneo Have you verified that the default: now statement is indented correctly? It has to be a sibling to time:, not its child.

sandersolvak commented 2 years ago

and this has worked fine ever since 3.6.2 – it sets both date and time to the current moment, as expected.

can confirm, works fine in 3.6.2

texnixe commented 2 years ago

I can also confirm that the date field works absolutely correctly.

I think @vivaneo actually has a different problem, which relates to the slug field adding zeros for the time even when the date has no time set.

Syncing slug field with date:

Slug field used with date field with time:

Bildschirmfoto 2022-05-07 um 14 17 25

Slug field used with date field without time:

Bildschirmfoto 2022-05-07 um 14 17 50

This happens because $store stores the date field with the time (e.g 2019-06-25 00:00:00).

See https://forum.getkirby.com/t/date-field-doesnt-save-hours-and-minutes-on-page-creation/21112/2

vivaneo commented 2 years ago

I think you're right.

I use the "kirby-plugin-custom-add-fields" plugin which is used to copy data to another field (synchronization).

I want to copy the title in the url:

  1. I transform the title field into a date (without hour or minute).
  2. The copy works but automatically adds me at the end 00-00-00

Note: the hour, the minutes and the seconds do not interest me.

Is it a plugin, browser or getkirby problem?

texnixe commented 2 years ago

Is it a plugin, browser or getkirby problem?

As I wrote above, in the Panel store, the date is stored with the zeros for the time no matter what you set in the blueprint. And the slug field then uses this $store value for synching. So it is somehow an issue with the date field but only in combination with the slug field. On the other hand I wonder why you even need the slug field if you want to create the slug from the date, unless you want to be able to modify it manually?