db中的数据类型为<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class='story' id='story'>
loem ipsum <span style="font-size: 1.3em;">lorem ipsum</span> lorem ipsum
</div>
<br>
<button>CLICK</button>
模型类:
time(7)
控制器:
public DateTime intime { get; set;}
public DateTime out_time { get; set;}
如果我转换为 DateTime newintime = DateTime.Parse(Request["intime"]);
DateTime newouttime = DateTime.Parse(Request["out_time "]);
model = db.bookm.Where(x=>x.intime>= newintime && x.out_time <= newouttime ).First();
,则可以使用。
我想将其插入,例如(18:23:44)
答案 0 :(得分:1)
I guess your database is MS SQL Server.
SQL Server stores time in HH:MI:SS
format.
Use TimeSpan
in your model to store/get the data.
Here is another possible solution: How to save time only without the date using ASP.NET MVC 5 Data Annotation "DataType.Time?
答案 1 :(得分:0)
DateTime newintime = DateTime.Parse(Request["intime"].ToLongTimeString()); //change here
DateTime newouttime = DateTime.Parse(Request["out_time"].ToLongTimeString());// here also
model = db.bookm.Where(x=>x.intime>= newintime && x.out_time <= newouttime ).First();
用户ToLongTimeString();