我怎么能缩短约会时间 [英] how can i short date

查看:134
本文介绍了我怎么能缩短约会时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从gridview的数据库得到了像2010-12-13 12:59:16.593这样的日期我希望反手2010-12-13这样的日期我怎么能这样做...

解决方案

如果您还没有将日期作为 DateTime结构 [ ^ ],使用 DateTime.TryParseExact() [ ^ ]将它送到那里。



然后,你可以使用< a href =http://msdn.microsoft.com/en-us/library/zdtaw1bw(v=vs.110).aspx> DateTime.ToString(string) [ ^ ]重载指定要显示的内容。


对于gridview中的显示日期时间格式2010-12-13



 < asp:BoundField  DataField =YourDateFieldHeaderText = SomeHeader
DataFormatString ={ 0 yyyy-MM-dd} />


检查您的列是否采用了日期时间值但采用varchar格式。



列格式应为DateTime,然后您可以将其格式更改为

in backend

date.ToString(yyyy- MM-dd);



和Html gridview设计方面如上文所述

DataFormatString ={0:yyyy-MM- dd}



NB

只需确保将HtmlEncode属性设置为False或它不会工作


i got the date like 2010-12-13 12:59:16.593 from the database in gridview i want to fornate date like 2010-12-13 in backhand how can i do that...

解决方案

If you don't already have the date as an instance of the DateTime structure[^], use DateTime.TryParseExact()[^] to get it there.

Then, you can use the DateTime.ToString(string)[^] overload to specify what you want it to be displayed as.


For display date time format 2010-12-13 in gridview

<asp:BoundField DataField="YourDateField" HeaderText="SomeHeader"
                    DataFormatString="{0:yyyy-MM-dd}"  />


Check whether your column is taking datetime value but with a varchar format.

Column format should be DateTime then you can change it's format to
in Backend
date.ToString("yyyy-MM-dd");

and in Html gridview design side do as above article
DataFormatString="{0:yyyy-MM-dd}"

N.B.

Just make sure you set the HtmlEncode attribute to False or it won't work.


这篇关于我怎么能缩短约会时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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