C#中的时间格式 [英] time format in c#

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

问题描述

你好.
我的表中有一列名为ShowTime,它的数据类型为time(7).
我不允许更改数据类型.
该列中的数据采用以下格式:13:09:49.5577199
现在我希望它显示在下拉列表中,例如01:09 PM

如何做到?

hello.
I have a column in my table with the name ShowTime and it has time(7) datatype.
I am not allowed to change tht datatype.
the data in this colum is in this format, 13:09:49.5577199
now i want it to be displayed in a dropdownlist like 01:09 PM

how to do it?

推荐答案

在DropDownList中添加DataTextFormatString ="{0:hh:mm tt}",
试试这个,
Add DataTextFormatString="{0:hh:mm tt}" in DropDownList,
Try this,
<asp:DropDownList ID="DropDownList1" runat="server" DataTextFormatString="{0:hh:mm tt}">




样本添加自定义DateTime格式,如
Hi,

Sample add custom DateTime Formating like as
String.Format("{0:t}", datetime); Output "4:05 PM" .




or

String.Format("{0:T}", datetime); output "4:05:07 PM".


跟随此链接
日期时间格式化


follow this link
DateTime Formating


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

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