如何只获得时间 [英] how to get only time in asp.ent

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

问题描述

大家好,


我有15:45的时间.我只想几个小时.如何获取.我希望结果是15


谢谢

Mohd wasif

Hi all,


I have time as 15:45 .I want only hours .How to get it.I want result as 15


Thanks

Mohd wasif

推荐答案

没有只有时间"这样的东西. 上午11点"表示无数个时间点:今天,明天,昨天-如果您只需要显示小时的一分钟,一分钟,一秒的时间,这就是时间结构实例的字符串格式问题.基本上,您需要使用System.DateTimeToString(string format).

请参阅:
http://msdn.microsoft.com/en-us/library/system.datetime.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/zdtaw1bw.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx [ ^ ].

最后一个链接指向对自定义格式字符串的引用.例如,使用someTime.ToString("HH");它会使用00到23之间的24小时制为您提供时间.

-SA
There is no such thing as "only time". "11 AM" means an infinite number of time points: today, tomorrow, yesterday— If you need to present just, say hour-minute-second part of time, this is a matter of string formatting of an instance of a time structure. Basically, you need to use System.DateTimeToString(string format).

Please see:
http://msdn.microsoft.com/en-us/library/system.datetime.aspx[^],
http://msdn.microsoft.com/en-us/library/zdtaw1bw.aspx[^],
http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx[^].

Last links points to the reference to the custom format strings. For example, use someTime.ToString("HH"); it will give you the hour, using a 24-hour clock from 00 to 23.

—SA


使用DateTime.Hour

这篇关于如何只获得时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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