Php 这是什么样的时间格式;P16DT1H58M47S”是什么;?

Php 这是什么样的时间格式;P16DT1H58M47S”是什么;?,php,datetime-format,time-format,Php,Datetime Format,Time Format,我正在使用PHP解析网站上的一些数据,它给了我以下格式的时间: P16DT1H58M47S 但他们并不总是有天数,就像这样: PT8H10M3S 有时没有时间: PT33M57S 我需要找到一种方法将其转换为总秒数。我不需要将其放入日期对象中,但我希望找到一种相当快速的方法,因为我有很多数据要处理。 就这样,谢谢!我现在使用的是这样的格式:echo$date->format(“%d天%h小时%I分钟%s秒”)就是这样,谢谢!我现在使用的是这样的格式:echo$date->format(“

我正在使用PHP解析网站上的一些数据,它给了我以下格式的时间:

P16DT1H58M47S
但他们并不总是有天数,就像这样:

PT8H10M3S
有时没有时间:

PT33M57S
我需要找到一种方法将其转换为总秒数。我不需要将其放入日期对象中,但我希望找到一种相当快速的方法,因为我有很多数据要处理。


就这样,谢谢!我现在使用的是这样的格式:
echo$date->format(“%d天%h小时%I分钟%s秒”)就是这样,谢谢!我现在使用的是这样的格式:
echo$date->format(“%d天%h小时%I分钟%s秒”)
Interval specification.

The format starts with the letter P, for "period."  
Each duration period is represented by an integer value  
followed by a period designator.  
If the duration contains time elements,  
that portion of the specification is preceded by the letter T.

--------------
Y   years
M   months
D   days
W   weeks. These get converted into days, so can not be combined with D.
H   hours
M   minutes
S   seconds
P16DT1H58M47S = 16 days, 1 hour, 58 minute and 47 seconds