Skip to content
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

When date changes, time is reseted to 12:00 #1393

Closed
danielcharrua opened this issue Jun 5, 2018 · 12 comments
Closed

When date changes, time is reseted to 12:00 #1393

danielcharrua opened this issue Jun 5, 2018 · 12 comments

Comments

@danielcharrua
Copy link

Hello, I'm using your plugin and it's a great plugin! but if I have a default date time defined and change date, time is reseted to 12:00.

For example if I'm using 2018-05-05 14:05 and change date the time is reseted to 12:00.
Is there any way to change date but keep the time?

I have also tried the the main website and the same is happening, you can check it here https://flatpickr.js.org/examples/#datetimepicker-with-limited-time-range I suppose that this is intended.

  • flatpickr version used: v4
  • Browser name and version: Chrome, Safari
  • OS and version: Mac High Sierra 10.13.4
@tantuffah
Copy link

Hi.
I have the same issue. Checking the file flatpickr.js, in the function selectDate(e) I found:

[...]
setHoursFromInputs(); //row 1716
[...]
setDefaultHours(); // row 1728
[...]

It looks to me that first the time is setted in the right way and the it's setted to default value.

I commented out the setDefaultHours() line and now looks like is working good, but I don't know if this change can introduce some regression.

Hopefully someone of the team can give us a better answer.

bye,
/tan

@LiamDawe
Copy link

LiamDawe commented Jun 9, 2018

Yup, this behaviour shows in their example page too, would love to see this officially fixed.

@danielcharrua
Copy link
Author

Hey, this issue is also present in example page as @LiamDawe says. I would also love to see this fixed or maybe a developer answer.

@kpolders
Copy link

I'm running into the same problem, and would love a solution for it!

@LaisneMael
Copy link

LaisneMael commented Jun 12, 2018

I had the same problem and I figured out that it was because in my dateFormat I forgot to add the time.

Changing from "d-m-Y" to "d-m-Y H:i" did the job !

@danielcharrua
Copy link
Author

Hello @LaisneMael, I have tried that but this is not working, I'm using the correct dateFormat. And please take a minute to test the example page: https://flatpickr.js.org/examples/#datetimepicker-with-limited-time-range
First select date and then time, suppose 09:00 and then change date. Time reset itself to 12.00, and in the example page I don't think they have an error...

Any ideas @chmln (author) we need a fix here!

@LaisneMael
Copy link

Hi @danielcharrua, sorry I misunderstood your problem. Mine was that every time I changed the hours it instantly reset to 12.00.

I think your issue is the normal behaviour as explained in @tantuffah 's answer. If you don't want this you'll need to comment setDefaultHours(); in the selectDate(e) function.

Maybe in the future @chmln can add an option to turn off this behaviour.

@Techn1x
Copy link

Techn1x commented Jul 1, 2018

Yep, I'm also experiencing this bug. Would really like the time not set back to default on each date selection..

@Techn1x
Copy link

Techn1x commented Jul 1, 2018

I believe this is also severely affecting the usability of the datepicker when mode is 'range' and time is enabled - makes it very hard to select the time for the start/end.

chmln added a commit that referenced this issue Jul 1, 2018
@chmln
Copy link
Member

chmln commented Jul 1, 2018

Hello,

This is now fixed on master and will be a part of the next release very soon.
Thank you all for patience :)

@dylanmcgowan
Copy link

What's the status here? I'm dealing with errors too.

I pass a date obj in to the input's value (with a time other than 12:00 am) and it still displays that way.

@danielcharrua
Copy link
Author

Hi this is fixed in v4.5.1 (latest)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants