Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

kyriakos

🏠
Working from home
View GitHub Profile
@kyriakos
kyriakos / posix2seconds.php
Created Sep 2, 2016
Convert ps etime to seconds in PHP - [[dd-]hh:]mm:ss
View posix2seconds.php
/* coverts process durations output from the ps linux command in the [[dd-]hh:]mm:ss format to seconds
* useful when you need to find long running processes in PHP
*/
function posixTimeToSeconds($str) {
$parts = explode(':', $str);
$c = count($parts);
if ($c == 2) {
return (int)$parts[0] * 60 + (int)$parts[1];
} else if ($c == 3) {
You can’t perform that action at this time.