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

How to convert time to seconds in php

藏色散人
Release: 2023-03-03 16:30:01
Original
3131 people have browsed it

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;
?>
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template