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

时间:2025-04-17 17:51:44
C#获取本地时间常用公式
//获取当前系统时间
DateTime dt = ;
//将系统时间转换成字符串
string strTime = ();
//长日期字符串
string strTime = ();
//短日期字符
string strTime = ();
//长时间字符串
string strTime = ();
//短时间字符串
string strTime = ();
//yyyyMMdd
string strTime = (“yyyyMMdd”);
//yyyy-MM-dd HH:mm
string strTime = (“yyyy-MM-dd HH:mm”);