flatpickr / flatpickr

lightweight, powerful javascript datetimepicker with no dependencies
https://flatpickr.js.org
MIT License
16.13k stars 1.46k forks source link

DateTime range with two inputs #584

Closed mgibbs189 closed 7 years ago

mgibbs189 commented 7 years ago

JSFiddle: https://jsfiddle.net/8q7h7tff/

Expected Behavior

After selecting a date range (start + end), I should be able to somehow edit the start time.

Current Behavior

After selecting the range, one cannot edit the start time without resetting the range.

Possible Solution

Perhaps we need separate time fields, or a way to distinguish between START time and END time.

See http://element.eleme.io/#/en-US/component/datetime-picker

Your Environment

chmln commented 7 years ago

Hello Michael,

I agree that a single input is not sufficient for user-friendly datetime range selection.

After selecting a date range (start + end), I should be able to somehow edit the start time.

allowInput: true

However note that flatpickr doesn't require vue.js and thus implementing multi-input ranges without bloating the source code is much harder.

Ideally, we could have nicer datetime range selections via plugins.

I'll get back to this after new docs are released.

alteredstudio commented 7 years ago

Can this mimic Airbnb's datepicker style with start and end calendars that show at the same time?

fboucquez commented 7 years ago

Hi guys, same problem here. I know it's a lot to ask, but any timeframe?

Maybe you could put 2 time pickers one next to the other taking 50% of the space each

chmln commented 7 years ago

@alteredstudio yes @fboucquez 3-4 weeks

https://github.com/chmln/flatpickr/issues/678#issuecomment-287193867

I'm planning to make a plugin to enable Airbnb-style range picking. Might take a few weeks due to me being incredibly busy with midterms and exams.

amnesia7 commented 7 years ago

What if minDate/maxDate could work with function as well as String and Date?

If that was the case, start and end date instances could be set to look at the opposite date field's value. i.e. the developer could set a maxDate function for start date field to be based on the value for end date if necessary and a minDate function for the end date field could be based on the value for the start date field value.

It might also be worth updating/setting the min/max attributes on the mobile/noCalendar fields themselves which wouldn't have any effect on text fields but would on date fields.

chmln commented 7 years ago

Almost ready :tada: rec_scheme

amnesia7 commented 7 years ago

Not wanting to be awkward but is it possible that it could allow for "To" being optional?

chmln commented 7 years ago

@amnesia7 this is a plugin, and plugins are optional by definition.

fboucquez commented 7 years ago

Great work! How does the time picker work with the 2 fields?

amnesia7 commented 7 years ago

@chmln what I was actually meaning was that it allowed the user to select either just From or From & To rather than forcing them to select a range. I suspect that it might make more sense to the user in this case though if they were separate fields.

abriginets commented 7 years ago

@chmln this is exactly what i wanted. Well done!

loveorigami commented 7 years ago

Very need this plugin! Thanks!

MartinMuzatko commented 7 years ago

can't wait for this.

foxdog05000 commented 7 years ago

Hello, is it possible to manage start and end times with this plugin? Otherwise how to do?

marijohannessen commented 7 years ago

Hi! Any update on when this will be available? Can't wait!

chmln commented 7 years ago

@foxdog05000 Yes! @marijohannessen by the end of this weekend

afabros commented 7 years ago

I also need this :| Having unlinked instances will just require too many codes to check if end date is after start date, that goes the same for time -- date ranges with time two inputs without having to remove ' to ' is really the perfect solution. Kindly help us know if this plugin is already available. Thank you for the hard work on flatpickr^^

screen shot 2017-05-31 at 2 34 06 pm
chmln commented 7 years ago

Hi all,

rangePlugin is now available at flatpickr@next.

Feel free to npm i flatpickr@next to try it out.

p.s. there are two breaking changes in v3:

abriginets commented 7 years ago

@chmln thank you very much for the work you have done! Flatpickr did one more step to become better and confirmed it's status as the best datetime picker 😃

marijohannessen commented 7 years ago

@chmln Thank you so much, really appreciate all the work you've done - you've saved me so much time! 🎉

ajayenuke commented 7 years ago

@chmln I need date range picker same as (https://github.com/chmln/flatpickr/issues/584#issuecomment-289295697). As you shown it on pictorial representation on previous comment. I need to use it as Vue js component. Please provide any documentation for the same.

foxdog05000 commented 7 years ago

@chmln Nice job, thanks you so much !

vangelis183 commented 7 years ago

@chmln Hi, is there an example for the usage of the rangePlugin with two input Fields as shown on your Image here: https://github.com/chmln/flatpickr/issues/584#issuecomment-289295697

chmln commented 7 years ago

@vangelis183 not yet, but it will be available this weekend as I update the documentation :+1:

AlingChen commented 7 years ago

@chmln Thank you so much, can't wait for it. By the way, is the example ready yet? :)

omartawba1 commented 7 years ago

@chmln Thanks for adding it, But I can't find example to make range picker with two inputs in the documentation!

afabros commented 7 years ago

@omartawba1 you can find @chmln 's example at https://github.com/chmln/flatpickr/issues/873... still have issue that with two input results though, "start_date_time" => "June 21, 2017 4:14 PM" "end_date_time" => "2017-06-14 16:14 to 2017-06-21 16:14"

chmln commented 7 years ago

Hey guys, sorry for the delays, I've just gotten back from a vacation.. The docs will be updated tonight and I'll add a link here as soon as they're ready.

Thank you for your patience

pasairnav commented 7 years ago

Any updates on this?

mattmewton commented 7 years ago

I too am looking for updates on this. @chmln have you had a chance to update the documentation for this new feature?

javlc commented 7 years ago

Hello Gregory, First of all, thank you for this awesome-looking date picker plugin. Eagerly awaiting for the docs on the date range using two inputs. Next Monday my dev team is to decide which date range picker plugin to use, and I am favoring this one, if I ever get the date range to work on two inputs. (I will be using the ember addon that wraps flatpickr). Cheers!

cc: @chmln

chmln commented 7 years ago

Here's a quick how-to while I upgrade the docs and release v3.1

HTML:

    <label>Date 1
      <input placeholder="Select Date..." />
    </label>

    <label>Date 2
      <input placeholder="Select Date..." id="input2" />
    </label>

JS:

flatpickr("input", {
    plugins: [new rangePlugin({ input: "#input2"})]
});

Plugin options:

interface Config {
  input?: string | HTMLInputElement;
}
chmln commented 7 years ago

https://chmln.github.io/flatpickr/plugins/#rangeplugin-beta

nicovanzyl commented 6 years ago

Would this be possible with two inline pickers?

xcrap commented 6 years ago

I've detecting some bugs in the rangePlugin. After you select a date, in the second selection when you change the year it don't update the date anymore.

chmln commented 6 years ago

@xcrap please open a new issue for this

Kryptonit3-zz commented 6 years ago

Any way for the value of input 1 to be 2018-05-09 instead of 2018-05-09 to 2018-05-11 ?

Kryptonit3-zz commented 6 years ago

guess I could do this

    flatpickr('#jobDateStart', {
        altInput: true,
        altFormat: "F j, Y",
        dateFormat: "Y-m-d",
        minDate: new Date(),
        "plugins": [new rangePlugin({ input: "#jobDateEnd"})],
        onChange: [function(selectedDates){
            const dateArr = selectedDates.map(date => this.formatDate(date, "Y-m-d"));
            $('#jobDateStart').val(dateArr[0]);
        }]
    });
lieunttuit commented 5 years ago

@chmln Hi, Would this be possible with two inline picker?

strarsis commented 4 years ago

Has this been solved now?

mahajan1217 commented 4 years ago

when we select startDate and same endDate it only shows startDate in mode range. any solution to this

enes9103 commented 5 months ago

when we select startDate and same endDate it only shows startDate in mode range. any solution to this

I am also looking for a solution to the same problem.

massimoghm commented 2 weeks ago

I hope I can help. The second input need type text.

Best regards