MVC4日期差异 [英] MVC4 Date difference

查看:75
本文介绍了MVC4日期差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MVC4日期差异



如何在下面的表格中显示2个日期之间的天数差异?

我可以使用viewbag吗?或者向页面控制器添加方法?



MVC4 Date difference

How can i show the days difference between 2 dates in the below form?
Could i use the viewbag or add a method to the page controller?



@ Html.EditorFor(model = > model.BookingFrom)

@ Html.ValidationMessageFor(model => model.BookingFrom)


@Html.EditorFor(model => model.BookingFrom)
@Html.ValidationMessageFor(model => model.BookingFrom)






@ Html.EditorFor(model => model.BookingTo)

@ Html.ValidationMessageFor(model => model.BookingTo)


@Html.EditorFor(model => model.BookingTo)
@Html.ValidationMessageFor(model => model.BookingTo)






@ Html.EditorFor(model => model.BookingDays)

@ Html.ValidationMessageFor(model => model.BookingDays)


@Html.EditorFor(model => model.BookingDays)
@Html.ValidationMessageFor(model => model.BookingDays)





比如根据所选日期自动弹出的BookingDays

如果可能的话仅限工作日



Would like the BookingDays to auto popluate depending on the days selected
If possible would like working days only

推荐答案

您无需发送服务器调用以获取日期差异。通过使用Javascript或jquery,您可以计算客户端本身的差异

我强烈建议使用优秀的datejs框架轻松完成所有日期时间计算

http://www.datejs.com/ [ ^ ]

希望这有帮助
You no need to send a server call for taking the date difference. By using Javascript or jquery you can calculate the difference inthe client side itself
I highly recommend using the excellent datejs framework to easily do all your date time calculations
http://www.datejs.com/[^]
Hope this helps


这篇关于MVC4日期差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆