如何在mvc应用程序中将日期选择器设置为dd / mm / yy [英] how to set date picker as dd/mm/yy in mvc application

查看:57
本文介绍了如何在mvc应用程序中将日期选择器设置为dd / mm / yy的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi to all,
          Here i create datapicker for my start date field and another fields as end date .Now i need to show date format as dd/mm/yy. 
Here i used below script .If i change date  as 13-12-2014 i got error date field must be a date, how to resolve this issue.Kindly help me for this

  $('#IssueDate').datepicker({
            dateFormat: 'dd/MM/yy', minDate: 0, maxDate: 0
        });

推荐答案

('#IssueDate')。datepicker({
dateFormat:'dd / MM / yy',minDate:0,maxDate:0
});
('#IssueDate').datepicker({ dateFormat: 'dd/MM/yy', minDate: 0, maxDate: 0 });


使用

Use
dateFormat : 'dd/mm/yy'





MM将返回月份name。



MM will return the month name.


1. ASP.NET MVC应用程序的视图使用当前的UI文化(以及控制器代码当前文化)来管理格式显示以及DateTime和数字的转换(整数,浮点数,双精度值。因此,在您的情况下,似乎当前的文化是为英语设置的,这会产生异常。



2.为了解决您的问题,您应该设置,在您的控制器,正确的当前UI文化以及当前文化值,如下例所示:

1.The ASP.NET MVC application's view is using the current UI culture (and in the controller code current culture) for managing the format show and the conversion of DateTime and numbers (integer, float, double) values. So in your case it seems that the current culture is set up for English and this generate exception.

2.In order to solve your problem you should set, in your controller, the correct current UI culture and also current culture values needed like in the next example:
Thread.CurrentThread.CurrentUICulture = new CultureInfo("de-DE");
//
// Set the thread's CurrentCulture the same as CurrentUICulture.
Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture;





PS:如果你想在MVC网络应用程序的上下文中找到关于多语言的更多细节,你可以阅读我的下一篇文章:MVC基本站点:第1步 - 多语言站点骨架 [ ^ ](如果需要MVC4的代码获取来自本系列的第2或第3篇文章。)



PS: If you want to find more details about multilingual in the context of an MVC web application you could read my next article: MVC Basic Site: Step 1 – Multilingual Site Skeleton[^] (If you need code for MVC4 get it from the 2nd or 3rd articles from this series.)


这篇关于如何在mvc应用程序中将日期选择器设置为dd / mm / yy的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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