什么是mvc3中正确的日期格式 [英] what is proper Date format in mvc3

查看:92
本文介绍了什么是mvc3中正确的日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

mvc3中的正确日期格式是什么

i我收到错误

选择日期作为无效日期

并设置日期格式





<前lang =c#> 受保护 void Application_BeginRequest()
{

System.Globalization.CultureInfo newCulture =(System.Globalization.CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture。克隆();
newCulture.DateTimeFormat.ShortDatePattern = dd / MM / yyyy;
newCulture.DateTimeFormat.DateSeparator = /;
System.Threading.Thread.CurrentThread.CurrentCulture = newCulture;
}

解决方案

 


< blockquote> .validator.addMethod(' date'
函数(value,element,params){
if this .optional(element)){
return true ;
}

var ok = true ;
尝试 {


.datepicker.parseDate(' dd / mm / yy',value);
}
catch (错误){
ok = false ;
}
return ok;
});





本作品


what is proper Date format in mvc3
i am getting error
while selecting date as invalid date
and have set date format


protected void Application_BeginRequest()
       {

           System.Globalization.CultureInfo newCulture = (System.Globalization.CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone();
           newCulture.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy";
           newCulture.DateTimeFormat.DateSeparator = "/";
           System.Threading.Thread.CurrentThread.CurrentCulture = newCulture;
       }

解决方案


.validator.addMethod('date', function (value, element, params) { if (this.optional(element)) { return true; } var ok = true; try {


.datepicker.parseDate('dd/mm/yy', value); } catch (err) { ok = false; } return ok; });



This Works


这篇关于什么是mvc3中正确的日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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