c#中如何获取当前时间??

YOULOVEXIA 2009-03-22 09:17:26
在c#中怎样获取当前时间??
...全文
928 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
duanyuncanyang 2009-06-19
  • 打赏
  • 举报
回复
System.DateTime.Now
tonylovelinyu 2009-03-24
  • 打赏
  • 举报
回复
hu
newgoodluck 2009-03-23
  • 打赏
  • 举报
回复
System.DateTime.Now
LiDongguang1013 2009-03-22
  • 打赏
  • 举报
回复
System.DateTime.Now
E_wait 2009-03-22
  • 打赏
  • 举报
回复
看书要认真,要多动手多动脑!呵呵
热学沸腾56 2009-03-22
  • 打赏
  • 举报
回复
System.DateTime.Now
Sfly_189 2009-03-22
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 wuyi8808 的回复:]
System.DateTime.Now
[/Quote]
正解
ljb07976513524 2009-03-22
  • 打赏
  • 举报
回复
--DateTime 数字型
System.DateTime currentTime=new System.DateTime();
1.1 取当前年月日时分秒
currentTime=System.DateTime.Now;
1.2 取当前年
int 年=currentTime.Year;
1.3 取当前月
int 月=currentTime.Month;
1.4 取当前日
int 日=currentTime.Day;
1.5 取当前时
int 时=currentTime.Hour;
1.6 取当前分
int 分=currentTime.Minute;
1.7 取当前秒
int 秒=currentTime.Second;
1.8 取当前毫秒
int 毫秒=currentTime.Millisecond;
(变量可用中文)



1.9 取中文日期显示——年月日时分
string strY=currentTime.ToString("f"); //不显示秒



1.10 取中文日期显示_年月
string strYM=currentTime.ToString("y");



1.11 取中文日期显示_月日
string strMD=currentTime.ToString("m");



1.12 取当前年月日,格式为:2003-9-23
string strYMD=currentTime.ToString("d");
freeboy827 2009-03-22
  • 打赏
  • 举报
回复
DateTime.Now
qlg270 2009-03-22
  • 打赏
  • 举报
回复
this.textBox1.Text=System.DateTime.Now.ToString();
iloverenne 2009-03-22
  • 打赏
  • 举报
回复
System.DateTime.Now
如果要去除时分秒之类可以再加System.DateTime.Now.(方法名)
Jacken_Wang 2009-03-22
  • 打赏
  • 举报
回复
System.DateTime.Now
liudanking 2009-03-22
  • 打赏
  • 举报
回复
其实这种问题LZ看书的时候应该知道的
这是最最基本的
n_yHHy_n 2009-03-22
  • 打赏
  • 举报
回复
System.DateTime.Now
yl0618 2009-03-22
  • 打赏
  • 举报
回复
System.DateTime.Now
wuyi8808 2009-03-22
  • 打赏
  • 举报
回复
System.DateTime.Now
YOULOVEXIA 2009-03-22
  • 打赏
  • 举报
回复
??

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧