如何从DateTime数据类型表中的标签中显示时间(hh:mm AM/PM) [英] How to show Time(hh:mm AM/PM) in Label from Table of DateTime DataType

查看:90
本文介绍了如何从DateTime数据类型表中的标签中显示时间(hh:mm AM/PM)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的先生,

我只想从表数据(DataType:DateTime)中显示Time(hh:mm AM/PM),就像''2011-08-30 00:00:00.000''
它在GridView中显示正确:使用DataFormatString ="{0:hh:mm}"

Dear Sir,

I want to show Time(hh:mm AM/PM) only from Table Data (DataType:DateTime),it is like ''2011-08-30 00:00:00.000''
it shows correct in GridView : using DataFormatString="{0:hh:mm}"

<asp:BoundField DataField="E_time" HeaderText="Time" DataFormatString="{0:hh:mm}"/>


同样,我想在标签中显示时间


Similarly I want to display Time in Label

<asp:Label ID="Label1" runat="server"></asp:Label>


如何格式化它.


How I can Format it.

推荐答案

<asp:boundfield datafield="E_time" headertext="Time" dataformatstring="{0:hh:mm tt}" xmlns:asp="#unknown" />


label1.Text = myDateTime.ToString("hh:mm tt");


这篇关于如何从DateTime数据类型表中的标签中显示时间(hh:mm AM/PM)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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