您当前的位置: 首页 >  光怪陆离的节日 c#

C#获取本地时间/系统时间

光怪陆离的节日 发布时间:2022-07-26 16:59:12 ,浏览量:3

C#获取本地时间常用公式
//获取当前系统时间
DateTime dt = System.DateTime.Now;
//将系统时间转换成字符串
string strTime = dt.ToString();
//长日期字符串
string strTime = dt.ToLongDateString();
//短日期字符
string strTime = dt.ToShortDateString();
//长时间字符串
string strTime = dt.ToLongTimeString();
//短时间字符串
string strTime = dt.ToShortTimeString();
//yyyyMMdd
string strTime = dt.ToString(“yyyyMMdd”);
//yyyy-MM-dd HH:mm
string strTime = dt.ToString(“yyyy-MM-dd HH:mm”);

关注
打赏
查看更多评论

光怪陆离的节日

暂无认证

  • 3浏览

    0关注

    916博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文
立即登录/注册

微信扫码登录