我怎样才能获得在C#中的当前时间? [英] how can i get the current time in C#?

查看:113
本文介绍了我怎样才能获得在C#中的当前时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要,但是当我创建一个DateTime对象,时间设置为00:00:00在C#当前时间。



如何才能得到时间的当前实例


解决方案

  DateTime.Now.ToString(HH:毫米:SS TT); 

这使得它给你作为一个字符串。


I need to get the current time in C# but when I create a DateTime object, the time is set to 00:00:00.

how can I get the current instance of time?

解决方案

DateTime.Now.ToString("HH:mm:ss tt");

this gives it to you as a string.

这篇关于我怎样才能获得在C#中的当前时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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