gpt4 book ai didi

c# - 转换日期时间格式?

转载 作者:行者123 更新时间:2023-11-30 19:01:53 25 4
gpt4 key购买 nike

我正在尝试将 12/20/2013 17:40 格式的日期时间转换为以下格式

2013 年 12 月 20 日下午 5:40。怎么可能?

最佳答案

您需要使用 DateTime.TryParseExact .应该这样做

string originalDate = "2/20/2013 17:40";
DateTime parsedDate;
if (DateTime.TryParseExact(originalDate, "M/dd/yyyy HH:mm", CultureInfo.InvariantCulture, DateTimeStyles.None, out parsedDate))
{
string requiredFormat = parsedDate.ToString("dd MMM yyyy hh:mm ttt");
}

输出:

20 Feb 2013 05:40 PM

关于c# - 转换日期时间格式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20682084/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com