Home >Backend Development >PHP Problem >How to convert time to seconds in php

How to convert time to seconds in php

藏色散人
藏色散人Original
2020-08-01 09:37:283130browse

How to implement php time to seconds: First create a PHP sample file; then pass "$parsed['hour'] * 3600 $parsed['minute'] * 60 $parsed['second']; " method to convert the specified time into seconds.

How to convert time to seconds in php

Recommendation: "PHP Video Tutorial"

Convert the time string in HH:MM:SS format into Seconds, you can use the date_parse function to parse specific time information.

<?php
  $time = &#39;21:30:10&#39;;
  $parsed = date_parse($time);
  $seconds = $parsed[&#39;hour&#39;] * 3600 $parsed[&#39;minute&#39;] * 60 $parsed[&#39;second&#39;];
  echo $seconds;
?>

The above is the detailed content of How to convert time to seconds in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Related articles

See more