vue-datepicker icon indicating copy to clipboard operation
vue-datepicker copied to clipboard

Set time via props

Open sebsobseb opened this issue 5 years ago • 3 comments

Hi,

Right now, when you select a date, the time is always the current time. This is fine in the majority of the cases. But, I think it would be useful if we could set the time of the date that is emitted to v-model.

Context: I have a project where we have a lot of datepickers for "from" and "until" dates. We always want to force the time of "from" dates to 00:00:00 and "until" dates to 23:59:59. Currently we always have to modify it after the date was picked. This feature would be pretty handy for this 🥇

Here are my 2 proposals:

  • Have 1 optional prop named set-time, which would accept a string in format HH:MM:SS
  • Have 3 optional props, one for each unit:
    • set-hours, which would accept an integer from 0 to 23.
    • set-minutes, which would accept an integer from 0 to 59.
    • set-seconds, which would accept an integer from 0 to 59.

Thanks!

sebsobseb avatar Aug 31 '20 14:08 sebsobseb

Hm i see your point but this isn't just "set the time to xy" because the datepicker can distinguishes between utc and the local timezone. If you use the utc prop the model of your datepicker can be different from what the picked date actual is. For example if you select 2020-08-01 and you are in a timezone before utc like somewhere in america with CDT which is -5 the model of the date would be 2020-07-31T19:00:00.

MrWook avatar Sep 04 '20 13:09 MrWook

@MrWook Ok, good point. Is it an option to only make it work when you don't use the utc prop?

sebsobseb avatar Sep 09 '20 06:09 sebsobseb

There is something wrong with this. The input and selected events are emitting a date with no time. Am i doing something wrong or is that new intended behavior

image

using latest version at this time: 3.2.1

djixadin avatar Jul 27 '21 10:07 djixadin