How to convert a “HH:MM:SS” string to seconds with PHP?

后端 未结 4 755
盖世英雄少女心
盖世英雄少女心 2020-12-18 01:20

Is there a native way of doing \"HH:MM:SS\" to seconds with PHP 5.3 rather than doing a split on the colon\'s and multipling out each section the relevant numbe

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-18 01:45

    Unfortunately not - as PHP isn't strongly typed there's no concept of a time type and hence no means to convert between such a string and a "seconds" value.

    As such, in practice people often split the string and multiply out each section as you mentioned.

提交回复
热议问题