文化和日期时间格式 [英] culture and datetime format

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

问题描述



我正在使用我的asp.net appliacation文化。我的网格有一个日期字段,显示格式为22/1/2008 00:00:00后面的代码


Thread.CurrentThread.CurrentCulture =新的CultureInfo(" en-GB")

如何删除小时,分钟,秒格式字符串?


谢谢

mp

Hi,
I am using culture for my asp.net appliacation .my grid is having a date field which displayes in the format 22/1/2008 00:00:00 after the below code

Thread.CurrentThread.CurrentCulture = New CultureInfo("en-GB")

how can i remove the hours,mintes,second in the format string ?

thanks
mp

推荐答案

当然,date.parse( thisDate,dd / MM / yyyy)应该可以工作。
Certainly, date.parse(thisDate,"dd/MM/yyyy") should work.


你希望我把这段代码放在哪里?

mp

where do u expect me to put this code ?
mp


当然,date.parse(thisDate,dd / MM / yyyy)应该有效。
Certainly, date.parse(thisDate,"dd/MM/yyyy") should work.


DateTime的默认.ToString()格式是你看到的小时和分钟。

你将如果你只想要日期部分,需要将它覆盖为类似.ToString(" mm / dd / yyyy")的东西。

如果你想要你也可以从你的SQL querry中删除时间部分,但该列将以字符串形式出现,而不是日期。 (尽管您可以对字符串执行DateTime.Parse()以获取DateTime对象)
The default .ToString() format for DateTime is to have the hours and minutes as you have seen.
You will need to override it to something like .ToString("mm/dd/yyyy") if you only want the date portion.
You can also remove the time portion from within your SQL querry if you want, but the column will come out as a string and not a date. (Although you could then do a DateTime.Parse() on the string to get a DateTime object)


这篇关于文化和日期时间格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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