基本信息
源码名称:c# 显示系统当前时间 示例代码
源码大小:0.05M
文件格式:.rar
开发语言:C#
更新时间:2017-04-11
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
System.DateTime currentTime = new System.DateTime();
currentTime = System.DateTime.Now;
MessageBox.Show(currentTime.ToString());
//取当前年
int year = currentTime.Year;
//取当前月
int month = currentTime.Month;
//取当前日
int day = currentTime.Day;
//取当前时
int hour = currentTime.Hour;
//取当前分
int minute = currentTime.Minute;
//取当前秒
int second = currentTime.Second;
//取当前毫秒
int millisecond = currentTime.Millisecond;
//取中文日期显示——年月日时分
string strY = currentTime.ToString("f");
MessageBox.Show(strY);
//取中文日期显示_年月
string strYM = currentTime.ToString("y");
//取中文日期显示_月日
string strMD = currentTime.ToString("m");
//取当前年月日,格式为:2003-9-23
string strYMD = currentTime.ToString("d");
MessageBox.Show(strYMD);
//取当前时分,格式为:14:24
string strT = currentTime.ToString("t");
//获取当前系统时间 完整的日期和时间
string y= DateTime.Now.ToString();
MessageBox.Show(y);
//只显示日期 xxxx年xx月xx日 ,一个是长日期
DateTime.Now.ToLongDateString();
//只显示日期 xxxx-xx-xx 一个是短日期
DateTime.Now.ToShortDateString();
//取当前年月日时分秒
System.DateTime currentTime = new System.DateTime();
currentTime = System.DateTime.Now;
MessageBox.Show(currentTime.ToString());
//取当前年
int year = currentTime.Year;
//取当前月
int month = currentTime.Month;
//取当前日
int day = currentTime.Day;
//取当前时
int hour = currentTime.Hour;
//取当前分
int minute = currentTime.Minute;
//取当前秒
int second = currentTime.Second;
//取当前毫秒
int millisecond = currentTime.Millisecond;
//取中文日期显示——年月日时分
string strY = currentTime.ToString("f");
MessageBox.Show(strY);
//取中文日期显示_年月
string strYM = currentTime.ToString("y");
//取中文日期显示_月日
string strMD = currentTime.ToString("m");
//取当前年月日,格式为:2003-9-23
string strYMD = currentTime.ToString("d");
MessageBox.Show(strYMD);
//取当前时分,格式为:14:24
string strT = currentTime.ToString("t");
//获取当前系统时间 完整的日期和时间
string y= DateTime.Now.ToString();
MessageBox.Show(y);
//只显示日期 xxxx年xx月xx日 ,一个是长日期
DateTime.Now.ToLongDateString();
//只显示日期 xxxx-xx-xx 一个是短日期
DateTime.Now.ToShortDateString();