服务器上的日期格式问题 [英] Date format problem on server

查看:199
本文介绍了服务器上的日期格式问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不是在谈论SQL Server或查询.

我说的是,日历控件可以控制其他任何日期控件.

当我选择2009年3月4日时,

我尝试将其设置为2009年4月3日(dd-MM-yyyy)

但这使我在服务器上的03/04/2009.

它在本地运行良好.但是在服务器上我得到了03/04/2009.

这是关于IIS服务器设置的,我已经知道IIS服务器上的设置是不同的.

我问如何更改?

我尝试了cultureinfo.GetCultureInfo,但一无所获.

它与客户端无关,而在服务器端

尽快给我 ans

我也尝试过

I am not talking about SQL server or Querries.

I am talking about, calendar controls any other date control.

When i choose 4 th march 2009,

i tried to set it as 04-03-2009 (dd-MM-yyyy)

but it turns me 03/04/2009 on server.

It runs fine on local. but on server i get 03/04/2009.

It is about IIS server setting and i already know that settings on IIS server is different.

I am asking how to change it?

I tried cultureinfo.GetCultureInfo but i got nothing.

It is not about client side but it is on Server side

give me as possible as fast ans

I tried also

DateTimeFormatInfo format = new DateTimeFormatInfo();
           format.ShortDatePattern = "dd/MM/yyyy";
          DateTime bookingDate = Convert.ToDateTime(strDate, format)

;

结果什么都不是.

;

result is nothing

推荐答案

dateValue.ToString("dd/MM/yyyy")将返回您所需的值.
这里的"dateValue"包含您从客户端收到的日期.
dateValue.ToString("dd/MM/yyyy") will return you required value.
Here ''dateValue'' contains the date that you have received from client side.


将此代码写入应用程序启动文件中.一世. e. Global.asax

Write this code in your Application Startup file. i. e. Global.asax

void Application_Start(object sender, EventArgs e)
{
	// Code that runs on application startup
	////Set date format
	CultureInfo newCulture = (CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone();

	newCulture.DateTimeFormat.ShortDatePattern = "dd-MMM-yyyy";

	Thread.CurrentThread.CurrentCulture = newCulture; 
}




我希望这能帮到您.我尝试过这个.




I hope this will help you. i tried this.


DateTime Formate [ ^ ]

http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx [ ^ ]
DateTime Formate[^]

http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx[^]


这篇关于服务器上的日期格式问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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