时间跨度为ISO8601时间格式字符串时间、跨度、字符串、格式

2023-09-04 01:52:01 作者:`。、麻吉們’

可以就如何转换时间跨度或INT到ISO8601时长串任何人提醒如 HTTP解释:?//en.wikipedia.org/wiki/ISO_8601#Durations

1小时30分钟会导致PT1H30M,例如:

  INT持续时间= 90;
字符串isoString = duration.ToIsoDuration();
 

解决方案

找到了解决办法我自己,所以我想我会分享:

 时间跨度时间跨度=新的时间跨度(0,值,0);
   返回XmlConvert.ToString(时间跨度);
 

wps 表格问题 判断字符串是否存在子字符串,同时进行提取

Can anyone advise on how to convert a timespan or int to an ISO8601 duration string as explained in http://en.wikipedia.org/wiki/ISO_8601#Durations?

"1 hour and 30 minutes" would result in "PT1H30M", for example:

int duration = 90;
string isoString = duration.ToIsoDuration();

解决方案

found the solution myself, so I thought I'd share:

   TimeSpan timeSpan = new TimeSpan(0, value, 0);
   return XmlConvert.ToString(timeSpan);