string aa = DateTime.Now.ToShortDateString();//"2019/9/23" string bb = DateTime.Now.ToShortTimeString();//"上午 10:21" string ff = DateTime.Now.ToLongDateString();//2019年9月23日 string gg = DateTime.Now.ToLongTimeString();//上午 10:22:07 int monthDays = DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month);//获取某月在某年中的天数 DateTime From = DateTime.ParseExact(/*tdFrom.Text*/"201909", "yyyyMM", DateTimeFormatInfo.InvariantInfo);//输入的String转Datetime DateTime End = DateTime.ParseExact(/*tdEnd.Text*/"201909", "yyyyMM", DateTimeFormatInfo.InvariantInfo); string nian = DateTime.Now.ToString("Y");//2019年9月 string nian1 = DateTime.Now.ToString("y");//2019年9月 string y1 = DateTime.Now.ToString("R");//Mon, 23 Sep 2019 10:31:48 GMT string y2 = DateTime.Now.ToString("r");//Mon, 23 Sep 2019 10:32:10 GMT string xingqiji = DateTime.Now.ToString("dddd");// "星期一" string zhouji = DateTime.Now.ToString("ddd");// "周一" string ri = DateTime.Now.ToString("dd");// 23 string ershisi = DateTime.Now.ToString("HH"); //3 string shier = DateTime.Now.ToString("hh");//15 string chang = DateTime.Now.ToString("F");//2019年9月23日 上午 10:34:08 string chang1 = DateTime.Now.ToString("f");//2019年9月23日 上午 10:34 string cahng2 = DateTime.Now.ToString("G");//2019/9/23 上午 10:35:07 string cahng3 = DateTime.Now.ToString("g");//2019/9/23 上午 10:35 string cahng4 = DateTime.Now.ToString("D");//2019年9月23日 string cahng5 = DateTime.Now.ToString("d");//2019/9/23 string now = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");//2019/09/23 10:14:54 string a = DateTime.Now.AddYears(20).ToString("yyyy/MM/dd HH:mm:ss");//2039/09/23 10:14:54 string b = DateTime.Now.AddMonths(-2).ToString("yyyy/MM/dd HH:mm:ss");//"2019/07/23 10:14:54" string c = DateTime.Now.AddDays(-8).ToString("yyyy/MM/dd HH:mm:ss");//"2019/09/15 10:14:54" string d = DateTime.Now.AddHours(24).ToString("yyyy/MM/dd HH:mm:ss");//"2019/09/24 10:14:54" string f = DateTime.Now.AddMinutes(1440).ToString("yyyy/MM/dd HH:mm:ss");//2019/09/24 10:14:54 string g = DateTime.Now.AddSeconds(3600).ToString("yyyy/MM/dd HH:mm:ss");//2019/09/23 11:14:54" string h = DateTime.Now.AddSeconds(3600).ToString("yyyy/MM/dd HH:mm:ss:ffff");//2019/09/23 11:14:54:7992
-
C#教程之C#实现的一些常见时间格式
本站最新发布 C#从入门到精通
试听地址 https://www.xin3721.com/eschool/CSharpxin3721/
试听地址 https://www.xin3721.com/eschool/CSharpxin3721/
技术的发展日新月异,随着时间推移,无法保证本博客所有内容的正确性,如有误导,请大家见谅!
栏目列表
最新更新
Winform中怎样跨窗体获取另一窗体的控件对
Winform中使用FastReport的PictureObject时通过代
三分钟掌握,使用Quqrtz.Net实现定时发送邮
NET/Regex 处理连续空格
QR 码详解(下)
C#中的等值判断1
C#编写了一个基于Lucene.Net的搜索引擎查询
使用FastReport报表工具生成报表PDF文档
基于JieBaNet+Lucene.Net实现全文搜索
C#取视频某一帧图片
.Net Standard(.Net Core)实现获取配置信息
Linux PXE + Kickstart 自动装机
Shell 编程 基础
Shell 编程 条件语句
CentOS8-网卡配置及详解
Linux中LVM逻辑卷管理
1.数码相框-相框框架分析(1)
Ubuntu armhf 版本国内源
Linux中raid磁盘阵列
搭建简易网站
Dubbo(五):深入理解Dubbo核心模型Invok
vfp教程之VFP与Excel交互编程
vfp教程之在VFP中实现跟变式组合框及椭圆
SQL SERVER查询数据库所有表的大小,按照记
使用 SQL 服务器时,"评估期已过期"错
sql server无法连接本地服务器
使用sql语句创建表
VB操作Access数据库小记 ————————
access数据库远程连接
java web操作Access数据库