你如何获得当前的时间? [英] How do you get the current time of day?

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

问题描述

如何获取当前时间(不是日期AND时间)?

How do you get the current time (not date AND time)?

示例:5:42:12 PM

Example: 5:42:12 PM

推荐答案

DateTime.Now.TimeOfDay 给你一个 TimeSpan (从午夜)。

DateTime.Now.TimeOfDay gives it to you as a TimeSpan (from midnight).

DateTime.Now.ToString(h:mm:ss tt)将它作为字符串给你。

DateTime参考: https://msdn.microsoft.com/en-us/library/system.datetime

DateTime reference: https://msdn.microsoft.com/en-us/library/system.datetime

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

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