C#将日期格式化为指定格式
private void btn_GetTime_Click(object sender, EventArgs e) { lab_time.Text = DateTime.Now.ToString("d") + "\n" +//使用指定格式的字符串变量格式化日期字符串 DateTime.Now.ToString("D") + "\n" + DateTime.Now.ToString("f") + "\n" + DateTime.Now.ToString("F") + "\n" + DateTime.Now.ToString("g") + "\n" + DateTime.Now.ToString("G") + "\n" + DateTime.Now.ToString("R") + "\n" + DateTime.Now.ToString("y") + "\n" + "当前系统时间为:"+DateTime.Now.ToString(//使用自定义格式格式化字符串 "yyyy年MM月dd日 HH时mm分ss秒"); }
付费内容,请联系本人QQ:1002453261
本文来自博客园,作者:明志德道,转载请注明原文链接:https://www.cnblogs.com/for-easy-fast/p/16462290.html