简体   繁体   English

jQuery date [时间]选择器-如何保存时间范围(+修改日期格式)?

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

I am using the datetime picker library and it works nicely. 我正在使用datetime选择器库,并且效果很好。

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 . 我已经将MySQL列从datetime更改为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 . 然后,我单击输入,并想要手动添加以下文本: - 12:00 : - 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 . 但是,当我在输入中键入此文本并单击输入时, - 12:00文本将消失,并且仅在以下输入中保留: 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. 理想情况下,如果您需要日期时间范围(与航空公司和酒店预订网站上的日期时间类似),则应该有2个日期时间选择器。 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() 在您的情况下,您需要时间范围,因此您可以使用DateTime.AddMinutes()添加时间

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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