如何从字符串转换为时间跨度 [英] How to convert from string to timespan
本文介绍了如何从字符串转换为时间跨度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从字符串转换为时间跨度
How to convert from string to timespan
推荐答案
查看此
TimeSpan Parsing [ ^ ]
TimeSpan ParseExact [ ^ ]
check this
TimeSpan Parsing[^]
TimeSpan ParseExact[^]
试试
try
string values = "000000006";
TimeSpan interval = TimeSpan.Parse(value);
如果你想将字符串转换为时间跨度,例如09:00 AM。试试这个
if you want to convert string to timespan for example "09:00 AM". Just try this
DateTime dt = DateTime.Parse("09:00 PM");
TimeSpan ts = new TimeSpan(dt.Hour, dt.Minute, dt.Second);
这篇关于如何从字符串转换为时间跨度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文