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

How to set a start and end time in the timepicker #167

Closed
betheymc opened this issue Nov 12, 2020 · 6 comments
Closed

How to set a start and end time in the timepicker #167

betheymc opened this issue Nov 12, 2020 · 6 comments

Comments

@betheymc
Copy link
Contributor

Hi,
I am using the timepicker to replace the jQueryUI timepicker. However, I can't seem to be able to set a start time in which all times before it in the day are disabled. I wonder if you have a way to do that, and if not, could that be something added? I think it would be very useful to a lot of plugin users.

Thank you in advance!

@stefangabos
Copy link
Owner

Have a look at this - this should get you on the right track

@betheymc
Copy link
Contributor Author

betheymc commented Nov 12, 2020

Okay thank you. This should help - does this code work when it is only the timepicker, and it is set in 12 hr format?
Also it would be great if I could get the minutes to work this way as well.

@stefangabos
Copy link
Owner

the code is generic, you'll have to adapt it to suit your needs

@betheymc
Copy link
Contributor Author

betheymc commented Dec 16, 2020

@stefangabos Is there a way to add an option to the plugin called something like "enabled_am_pm"?
It would only apply if the format is set to include the am/pm option, and would give the user the ability to enable/disable am and/or pm.
That way, if someone is trying to set start and end times in 12 hr format, they can use a combination of the enabled_am_pm option and the code you suggested here to successfully do it.

Let me know if that's something you can add.

Thank you!

~Beth

@stefangabos
Copy link
Owner

Setting a date format to one that has AM/PM will enable those (that means using a or A in the format; see docs for the possible format arguments)

@betheymc
Copy link
Contributor Author

betheymc commented Dec 16, 2020

@stefangabos Thank you. I do have it set that way. My current format for my time fields is "H:i a".
Maybe I wasn't making much sense earlier. I need a way to disable PM or AM only, like when you set enabled_hours to only certain hours, or enabled_minutes to only certain minutes.

My goal is to have two input timepickers (for start and end times), and write code so that, for example, if the user selects 2:30 PM in the first input, then the second input would automatically update so that all hours before "2" are disabled (using enabled_hours), and all minutes before "30" are disabled (using enabled_minutes). However, in 12 hr. time format, there is no enabled_ampm option, and in order to make my start and end times work correctly, I need to disable the "AM" option only, in this case.

Does that make more sense? Let me know if I can clarify more.

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

No branches or pull requests

2 participants