当前位置:网站首页>PHP converts seconds to timestamps - PHP

PHP converts seconds to timestamps - PHP

2022-07-04 07:52:00 45MA

There are total seconds in my watch , But I want to get one hh:mm:ss Such a time format ,
Currently I have, for example :seconds - 226 And I know that 4 branch 26 Second time format , But I have tried the following code :

$seconds = 226;$hours = floor($seconds / 3600);$mins = floor(($seconds - ($hours*3600)) / 60); $secs = floor(($seconds - ($hours*3600)) - ($mins*60));

This output 3:46

May there be a problem with the formula ?

edit : I returned from the video duration youtube This value is obtained in the script :

    $ytvidid = $url;$ytdataurl = "http://gdata.youtube.com/feeds/api/videos/". $ytvidid;$feedURL = $ytdataurl;$ch = curl_init();curl_setopt($ch, CURLOPT_URL, $feedURL);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);// get the result of http query$output = curl_exec($ch);curl_close($ch);// feed the curl output to simplexml_load_string$sxml = simplexml_load_string($output) or die("XML string not loading");//$sxml = simplexml_load_file($feedURL);$media = $sxml->children('http://search.yahoo.com/mrss/');// get <yt:duration> node for video length$yt = $media->children('http://gdata.youtube.com/schemas/2007');$attrs = $yt->duration->attributes();    echo $attrs['seconds'];

Reference plan

Use gmdate function, You can go to http://php.net/manual/en/function.date.php View the format code on

echo gmdate("H:i:s", $seconds);

PS. Your method has been effective . 226 Seconds will be 3 branch 46 second .

PHP set_time_limit Invalid - php

I have a very painful slow script , The script starts from MySQL Get a lot of data and create a lot of reports from it , And finally with the application / It is provided to users in the form of forced download . Cut a long story short , On the production server , It will be around 30 Terminate in seconds ( Quite stable ), Then spit out an empty file . On the development server , It works , But the execution time is much longer - about 90 second . For safety's sake , I will php.ini The file is set to max_execution_time = 200…

cURL- Load with CloudFlare Protected sites - php

I have a website , I want to use cURL load . however , The site I'm talking about is in use cloudflare Protect . stay cURL request => On , It said “ Check your browser , You will be at 5 Redirected within seconds ”, I was redirected to a non-existent page , Because I don't think I passed some protection tests . I have been looking for the answer for a long time , But I found only two useful links :Link 1Link 2 But I still can't figure it out . Will it help me ?…

Real time notification Jquery PHP - php

I try to implement a real-time notification , Such as facebook newsticker And notify the ( At the top ). I want to know what is the best solution to archive it . I implemented a chat application , Before that, I triggered AJAX GET Request to archive in real time , But it doesn't seem good . I checked with firefly Facebook, There is no trigger GET request ( Or it's hidden ?) Now this is my scene : stay main.php I have a real-time quotation machine and a pass …

PHP- Insert the date into the date time field - php

I have used in the database datetime Field storage date , Use PHP take “ Today's date ” What is the correct way to insert this field ? Let me propose a toast to , Reference plan I think you can use php date() function

PHP- How to get the list of member functions of a class ? - php

If I know the name of the class . Is there any way to know the list of member functions of a class ? Reference plan get_class_methods() It's your friend

原网站

版权声明
本文为[45MA]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202141517534521.html