在服务器上传时,datetime解析不起作用 [英] datetime parse not working while uploading in server

查看:71
本文介绍了在服务器上传时,datetime解析不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

DateTime.ParseExact(datetime,@d / M / yyyy,System.Globalization.CultureInfo.InvariantCulture).ToString();





此代码在本地服务器上运行..但上传时无法正常工作任何人都可以帮助...

DateTime.ParseExact(datetime, @"d/M/yyyy", System.Globalization.CultureInfo.InvariantCulture).ToString();


this code is working in local server .. but not working while uploading can anyone help...

推荐答案

您是否在服务器上查看文化格式? ?



您可以在system.web标签内的web.config文件中将其设置为应用程序级别:



have you check culture format at your server?

you can set it at application level from web.config file inside system.web tag as:

<system.web>

  <globalization culture="en-GB"/>





文化en-GB支持dd / MM / yyyy格式。

有关格式的更多信息,请查看此链接



http://www.basicdatepicker.com/samples/ cultureinfo.aspx



the culture "en-GB" supports dd/MM/yyyy format.
for more info about your format check this link

http://www.basicdatepicker.com/samples/cultureinfo.aspx


你传递的字符串可能与那个确切的格式不匹配:它可能是第一年,或者'/'可以替换为' - ',或者它可能包括前导零,或月份可能是APR或10月



为什么在互联网等国际系统上使用Invariant Culture?当然最好使用客户文化吗?

Probably, the string you are passing does not match that exact format: it may have the year first, or the '/' may be replaced with '-', or it may include leading zeros, or the month may be "APR" or "Oct"

Why are you using Invariant Culture on an international system such as the internet? Surely it would be better to use the Client culture?
Thread.CurrentThread.CurrentCulture = new CultureInfo(Request.UserLanguages[1]);

然后使用直接DateTime.TryParse解析日期?

And then parse the date with a straight DateTime.TryParse?


这篇关于在服务器上传时,datetime解析不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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