法1
System.DateTime currentTime = new System.DateTime(); //定义
currentTime = System.DateTime.Now; //取当年的日月时分秒
string strY = currentTime.ToString("f"); //不显示秒
法2
string strY = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm");
或string strY=DateTime.Now.ToString("yyyy年MM月dd日")
C#提取系统时间
最新推荐文章于 2024-09-09 17:03:46 发布