我有一个如下所示的字符串:
string expiredDate = "2026-05-24 18:54:55";
我想使用下面的代码将其转换为日期时间格式:
DateTime myDate = DateTime.ParseExact(expiredDate, "dd MMMM yyyy HH:mm:ss", CultureInfo.InvariantCulture);
但是它不起作用,我收到此错误:
我也尝试过使用
替换它DateTime expiredDate = DateTime.ParseExact(expiredDate, "dd MMMM yyyy HH:mm:ss", CultureInfo.CreateSpecificCulture("id-id"));
但我仍然遇到同样的错误。
如何解决?
那为什么不呢
DateTime myDate = DateTime.ParseExact(expiredDate, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);