Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有日期时间格式的值。例如:2012-10-17 00:05:00.000 我将它们转换为时间格式,例如:00:05:00.000 但对我来说仍然太长了。我只想要那段时间的小时和分钟部分。有人知道吗?
尝试这个:
var dateTime = new DateTime(2012, 10, 17, 0, 5, 0, 0); var hoursAndMinutes = dateTime.ToShortTimeString();