从数据库检索时出现时间格式问题 [英] Time format issue while retrieving from database

查看:78
本文介绍了从数据库检索时出现时间格式问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从sql数据库检索日期时间时出现问题.
我的列中的数据类型为DATE TIME.
我正在从头开始使用Java脚本日期时间选择器来保存日期时间,并选择以24小时格式保存时间.
它以24小时格式保存,但是当我在网格视图中显示该记录时
时间以12小时格式转换

例如,如果我要保存2012年7月5日17:35:00
如果我在网格视图或文本框中显示记录,则显示为07/05/2012 5:35:0 pm
我不知道这对任何解决方案或代码有什么帮助
我正在尝试但没有获得成功.

在此先感谢

I am having problem while retrieving date time from sq l database.
I have Column in with datatype as DATE TIME .
I am using java script date time picker in from end to save the date time with option to save the time in 24 hours format.
It getting save in 24 hours format but when i display that record in grid view
the time get converted in 12hours format

for example if i am saving 07/05/2012 17:35:00
if i am displaying the record in grid view or Text Box it show 07/05/2012 5:35:0 pm
i don''t what this can any one help me with this any solution or code
i am trying but not getting success .

Thanks in advance

推荐答案

尝试一下:

Try this :

<asp:boundfield datafield="Your_Date_Column" dataformatstring="{0:dd/MM/yyyy HH:mm}" htmlencode="false" xmlns:asp="#unknown" />



您需要放置htmlencode属性.
HTML编码字段值有助于防止显示跨站点脚本攻击和恶意内容.应尽可能启用此属性.



You need to put that htmlencode attribute.
HTML-encoding field values helps to prevent cross-site scripting attacks and malicious content from being displayed. This property should be enabled whenever possible.


这篇关于从数据库检索时出现时间格式问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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