gpt4 book ai didi

c# - 将 (0740) 等字符串时间转换为 12 小时 (AM,PM) 时间格式 (07 :40 AM)

转载 作者:行者123 更新时间:2023-12-02 09:39:32 24 4
gpt4 key购买 nike

如何将字符串时间转换为12 小时(AM、PM) 时间格式?喜欢如果输入字符串像“2320”,而不是我想要像“11:20 PM”这样的答案。

最佳答案

string s = DateTime.ParseExact("2320","HHmm",CultureInfo.CurrentCulture)
.ToString("hh:mm tt");

关于c# - 将 (0740) 等字符串时间转换为 12 小时 (AM,PM) 时间格式 (07 :40 AM),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1989533/

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