c# 2023-06-28 235700 装换成 2023-06-28
在C#中,可以使用DateTime.ParseExact方法将字符串转换为DateTime对象,并指定所需的格式。在这种情况下,格式为"yyyy-MM-dd"。以下是示例代码:
string input = "2023-06-28 23:57:00";
DateTime dateTime = DateTime.ParseExact(input, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
string result = dateTime.ToString("yyyy-MM-dd");
Console.WriteLine(result);
输出结果为:
2023-06-28
原文地址: https://www.cveoy.top/t/topic/hYQF 著作权归作者所有。请勿转载和采集!