1
我开发一个ASP.NET C#Web表单网站与MySQL作为数据库提供其标准的日期格式的日期。的Global.asax.cs自定义日期格式在整个网站
我如何添加一个自定义日期格式的文件Global.asax.cs中像如下(非工作代码):
using System.Globalization;
using System.Threading;
protected void Application_BeginRequest(Object sender, EventArgs e)
{
CultureInfo newCulture = (CultureInfo) System.Threading.Thread.CurrentThread.CurrentCulture.Clone();
//Will make all dates of the format similar to 3/14/13 12:9 AM/PM
newCulture.DateTimeFormat = "M/d/yy h:m tt";
Thread.CurrentThread.CurrentCulture = newCulture;
}
谢谢你的任何输入。
为什么你需要调用'CurrentCulture.Clone()',而不是简单地使用'CurrentCulture.DateTimeFormat.ShortDatePattern = “”'等? – Sinjai