如何将24小时格式的TimeSpan转换为12小时格式的TimeSpan? [英] how to convert 24-hour format TimeSpan to 12-hour format TimeSpan?
问题描述
我有以24小时格式表示的TimeSpan数据,例如14:00:00,我想将其转换为12小时格式,即2:00 PM,我用Google搜索并发现了与stackoverflow和msdn相关的内容解决不了这个问题,有人可以帮助我吗?预先感谢.
I have TimeSpan data represented as 24-hour format, such as 14:00:00, I wanna convert it to 12-hour format, 2:00 PM, I googled and found something related in stackoverflow and msdn, but didn't solve this problem, can anyone help me? Thanks in advance.
更新似乎可以将24小时格式的TimeSpan转换为String,但无法将字符串转换为12小时的格式TimeSpan:(
Update Seems that it's possible to convert 24-hour format TimeSpan to String, but impossible to convert the string to 12-hour format TimeSpan :(
但是我仍然有很多很好的答案,谢谢!
But I still got SO MANY good answers, thanks!
推荐答案
TimeSpan
表示时间间隔 而不是一天中的时间. DateTime
结构更可能是您正在寻找的结构
TimeSpan
represents a time interval not a time of day. The DateTime
structure is more likely what you're looking for.
这篇关于如何将24小时格式的TimeSpan转换为12小时格式的TimeSpan?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!