系统时间问题. [英] System Time Problem.

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

问题描述

我正在尝试通过
的简单编码来获取系统时间
System.DateTime.Today.ToString("hh:mm tt")
但是每次运行此代码时,都会得到相同的输出"12:00 AM"

为什么我的系统时间不在这里?
需要帮助!

i am trying to get the time of system by simple coding of

System.DateTime.Today.ToString("hh:mm tt")
But every time I run this code I get the same output of "12:00 AM"

Why my system time is not fetching here?
Need Help!!

推荐答案

而不是Today(仅是日期),请尝试使用Now:
Instead of Today (which is only the date), try using Now:
System.DateTime.Now.ToString...


实际上Mika已经给出了正确的解决方案,但是我想详细说明一下. DateTime.Today和DateTime.Now之间的区别在于,Today为您提供了当天的开始时间,这是:

2011-03-29T00:00:00,今天是12:00 AM.
现在也有当前时间附:2011-03-29T21:22:34

大概就是总结了!

干杯,
Actually Mika already gave the correct solution, but I wanted to elaborate a bit more. The difference between DateTime.Today and DateTime.Now is that Today give you the start of the current day and this is:

2011-03-29T00:00:00 which is today at 12:00 AM.
Now also has the current time attached: 2011-03-29T21:22:34

That just about sums it up!

Cheers,


这篇关于系统时间问题.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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