question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Flatpickr. On change wrong value

See original GitHub issue

https://codepen.io/gamevnlc/pen/LYpbqEw

Your Environment

  • flatpickr version used: 4.6.3
  • Browser name and version: Chrome
  • OS and version: MacOS 10.15.3

On change give incorrect datetime value when enableTime is enable for the first time open picker

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
gamevnlccommented, Apr 29, 2020

Screen-Recording-2020-04-29-at-9 39 26-AM @BRAiNCHiLD95 as you can see from my gif above. When I click on input box the alert dialog display follow step

  1. onValueUpdate 29/04 09:39 => My current time zone
  2. onChange 29/04 09:39 => My current time zone
  3. onValueUpdate 29/04 12:00 I assume that is default time from flatpickr
  4. onValueUpdate 29/04 12:00 again
  5. 29/04 12:00 in the input box Therefore I think onChange give incorrect value on the first time click.
2reactions
BRAiNCHiLD95commented, Apr 24, 2020

This is technically supposed to be the default behaviour.

You need to pass in the defaultDate yourself to make it use the current time. You can use simple JavaScript or any datetime wrapper like moment or Luxon -

defaultDate: new Date(),

You could also have defaultDate use a date coming from the database/any external source (useful in an “Edit” scenario) -

defaultDate: new Date(variableName)

Refer to https://flatpickr.js.org/options/ for other config options that you might need.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Flatpickr. On change wrong value - CodePen
Insecure Resource. The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https....
Read more >
Options - Flatpickr
Config Option Type Default altFormat String "F j, Y" altInput Boolean false altInputClass String ""
Read more >
onchange event is not woking on flatpickr() input
First change the order of your scripts: <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script> <script ...
Read more >
Flatpickr Vuejs Componet - Laracasts
I created Flatpickr Vuejs Component and it works fine but when I use static to ... el.children[1] }, /** * Watch for value...
Read more >
vue-flatpickr-component - npm
Vue.js component for Flatpickr date-time picker. Latest version: 11.0.1, last published: ... You can change flatpickr value programmatically.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found