简体   繁体   中英

jQuery date[time] picker - how to save time range (+ modify date format)?

I am using the datetime picker library and it works nicely.

But now, I am I need to save a time range. When I click to the widget, I am able to save a date and time in this format:

2015/03/15 10:15

This works well. But I would need to add a time range and save the date+time in this format:

2015/03/15 10:15 - 12:00

How to do that? I already changed the MySQL column from datetime to string . Now I am facing the problem how to enter the value to the input. When I chose the date+time, then in the input will occur something like this:

2015/03/15 10:15

Then I click to the input and want to manually add this text: - 12:00 . But when I type this text to the input and the click out of the input, the - 12:00 text will disappear and in the input stays only following: 2015/03/15 10:15 .

How to solve this problem? Any thoughts?

Thank you.

I think there might be a slight problem in your design. Ideally, if you need a datetime range (somewhat simliar to what you have on airline and hotel booking sites), you ought to have 2 datetime pickers. One for the start of the range and one for the end of the range. Even with the database. There would be one column for start date and another for end date.

In your case, you need the time range, so you could probably add the time using the DateTime.AddMinutes()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM