MVC 4.0 Datepicker Formating [英] MVC 4.0 Datepicker Formating

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

问题描述


我有这个

Hi I have this this

@ Html.TextBoxFor(model => model.RecievedDate,null,new {@ class =datepicker})
@Html.TextBoxFor(model => model.RecievedDate, null, new { @class= "datepicker"})



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


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




和jquery给出的默认日期格式为31/03/2014,我的数据库采用这种格式2014-03-31我如何格式化它以便我可以将它存储在数据库中?


and the jquery gives a default date format of 31/03/2014 and my database recives this kind of format "2014-03-31" how can i format it so that i can store it in the database?

推荐答案

使用ToString方法并传递格式字符串以获得所需的格式类型。

例如:

original_date =2014/12/31

changed_date = original_date.ToString(yyyy-mm-dd)//这会给你2014-12-31
use ToString method and pass the format string to get your required format type.
for example:
original_date = "2014/12/31"
changed_date = original_date.ToString("yyyy-mm-dd") //this will give you "2014-12-31"


这篇关于MVC 4.0 Datepicker Formating的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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