Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/257.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#和jQuery中的日期时间格式不一致_C#_Asp.net Mvc_Datetime - Fatal编程技术网

C#和jQuery中的日期时间格式不一致

C#和jQuery中的日期时间格式不一致,c#,asp.net-mvc,datetime,C#,Asp.net Mvc,Datetime,我有一个问题,我有一个基于用户的日期时间格式设置。 现在,我在Global.asax中设置输入格式,如下所示 void MvcApplication_PreRequestHandlerExecute(object sender, EventArgs e) { if (userSettings.Settings.ContainsKey(Constants.DateFormat)) {

我有一个问题,我有一个基于用户的日期时间格式设置。 现在,我在Global.asax中设置输入格式,如下所示

   void MvcApplication_PreRequestHandlerExecute(object sender, EventArgs e)
    {

                if (userSettings.Settings.ContainsKey(Constants.DateFormat))
                {
                    CultureInfo cultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture;
                    cultureInfo.DateTimeFormat.DateSeparator = "/";
                    cultureInfo.DateTimeFormat.FullDateTimePattern = userSettings.Setting.Attributes[Constants.DateFormat];
                    cultureInfo.DateTimeFormat.LongDatePattern = userSettings.Setting.Attributes[Constants.DateFormat];
                    cultureInfo.DateTimeFormat.ShortDatePattern = userSettings.Setting.Attributes[Constants.DateFormat];
                }
     }
但是,当我将UI文本框中的日期值绑定到属性时,只会得到空值。我在这个过程中遗漏了什么

用户提供的日期格式为“dd/mm/yy”。MVC模型绑定完成后,“01/11/12”的输入绑定为2012年1月11日

请建议问题以及解决方案将在何处解决

编辑

是否可以在日期格式字符串(如mm/dd/yy)中仅将月份作为第一个。是否不可能将dd/mm/yy作为格式字符串。

类似的内容

cultureInfo.DateTimeFormat.LongDatePattern = CultureInfo.CreateSpecificCulture("id-ID");

以印度尼西亚的文化为例,我们使用dd/MM/yyyy格式。

也许您应该研究一种正式的日期格式,然后进行本地化。我们选择使用ISO8601(现在是WebAPI的默认版本)。然后,您可以在客户机上确信您将从序列化格式中读取正确的日期。但是,您需要将时间本地化(如果需要)

斯科特·汉斯曼(Scott Hanselman)有很多问题


而且库看起来很有趣。

我从用户那里获得了日期-时间格式,必须为当前区域设置该值。您提供的示例用于设置区域性信息,并且您不能在datetimepattern上设置区域性