网站大量收购独家精品文档,联系QQ:2885784924

[建筑]18个实用的C时间函数.doc

  1. 1、本文档共5页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
[建筑]18个实用的C时间函数

DateTime数字型 System.DateTimecurrentTime=newSystem.DateTime(); C#时间函数1、取当前年月日时分秒 currentTime=System.DateTime.Now; C#时间函数2、取当前年 intyear=currentTime.Year; C#时间函数3、取当前月 intmonth=currentTime.Month; C#时间函数4、取当前日 intday=currentTime.Day; C#时间函数5、取当前时 inthour=currentTime.Hour; C#时间函数6、取当前分 intmin=currentTime.Minute; C#时间函数7、取当前秒 intsec=currentTime.Second; C#时间函数8、取当前毫秒 intmillisec=currentTime.Millisecond; C#时间函数9、取中文日期显示——年月日时分 stringstrY=currentTime.ToString(f);//不显示秒 C#时间函数10、取中文日期显示_年月 stringstrYM=currentTime.ToString(y); C#时间函数11、取中文日期显示_月日 stringstrMD=currentTime.ToString(m); C#时间函数12、取中文年月日 stringstrYMD=currentTime.ToString(D); C#时间函数13、取当前时分,格式为:14:24 stringstrT=currentTime.ToString(t); C#时间函数14、取当前时间,格式为:2008-09-23T14:46:48 stringstrT=currentTime.ToString(s); C#时间函数15、取当前时间,格式为:2003-09-2314:48:30Z stringstrT=currentTime.ToString(u); C#时间函数16、取当前时间,格式为:2003-09-2314:48 stringstrT=currentTime.ToString(g); C#时间函数17、取当前时间,格式为:Tue,23Sep200314:52:40GMT stringstrT=currentTime.ToString(r); C#时间函数18、获得当前时间n天后的日期时间 DateTimenewDay=DateTime.Now.AddDays(100);//100天后的日期时间 ------------------------------------------------------------------------------------------------------ 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); 1.13 取当前时分,格式为:14:24 string strT=currentTime.ToString(t); //今天 DateTime.Now.Date.ToShortDateString(); //昨天,就是今天的日期减一 DateTime.Now.AddDays(-1).ToShortDateString(); //明天,同理,加一 DateT

文档评论(0)

qiwqpu54 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档