2011-12-14 19 views
1

は、私はPHPを使用して、ウェブサイト上のいくつかのデータを解析していますし、それが私にこのフォーマットでの時間の量与えます:この「P16DT1H58M47S」はどのような時間形式ですか?

P16DT1H58M47S 

をしかし、彼らはいつものように、日数を持っていない:

PT8H10M3S 

そして、時には何時間:

PT33M57S 

私は見つけることが必要なものは、合計秒数にそれを変換する方法はありません。私はそれを日付オブジェクトに入れる必要はありませんが、私は多くのデータを持っているので、これを行うためのかなり簡単な方法を見つけたいと思います。それは感謝だった

答えて

5

http://www.php.net/manual/en/dateinterval.construct.php

 
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 
+0

!私は今のところこれを使っています: 'echo $ date-> format( '%d日%h時間%i分%秒'); ' – Vance

関連する問題