The below PHP function will take the Mikrotik time format (ex. 5d10h23m14s) and return it as number of seconds. From there it should be easy enough to convert it to hh:mm:ss or whatever else you want. There may even be a built in PHP function that already does it. Check
http://www.php.net. Of course, you'll have to run this on a PC and not on the MT itself. Currently it only calculates days, hours, minutes, and seconds but could easily be altered to handle weeks as well.
It starts at the left hand side of the MT output and checks to see if there are any days, if so it reads how many and then strips that part of the MT output off. Checks for hours, etc...
--------------------Beginning of Code------------------
<?php
function UptimeInSeconds($uptime) {
$mark1=strpos($uptime, "d");
$days=substr($uptime, 0, $mark1);
if ($mark1) $uptime=substr($uptime, $mark1 + 1);
$mark1=strpos($uptime, "h");
$hours=substr($uptime, 0, $mark1);
if ($mark1) $uptime=substr($uptime, $mark1 + 1);
$mark1=strpos($uptime, "m");
$minutes=substr($uptime, 0, $mark1);
if ($mark1) $uptime=substr($uptime, $mark1 + 1);
$mark1=strpos($uptime, "s");
$seconds=substr($uptime, 0, $mark1);
if ($mark1) $uptime=substr($uptime, $mark1 + 1);
$total=($days * 86400) + ($hours * 3600) + ($minutes * 60) + $seconds;
return $total;
}
?>
--------------------End of Code------------------
//
corrección
<?php
function secondsToTime($seconds) {
$dtF = new \DateTime('@0');
$dtT = new \DateTime("@$seconds");
$dias = $dtF->diff($dtT)->format('%a');
$horas = $dtF->diff($dtT)->format('%h');
$minutos = $dtF->diff($dtT)->format('%i');
$segundos = $dtF->diff($dtT)->format('%s');
$tiempo = "";
$coma = "";
if ($dias>0){
if ($dias>1){$tiempo .= $dias." Dias";}else{$tiempo .= $dias." Dia";}
$coma = ", ";
}
//
if ($horas>0){
if ($horas>1){$tiempo .= $coma.$horas." Horas";}else{$tiempo .= $coma.$horas." Hora";}
$coma = ", ";
}else{
$coma = "";
}
//
if ($minutos>0){
if ($minutos>1){$tiempo .=", ". $minutos." Minutos";}else{$tiempo .= ", ".$minutos." Minuto";}
}else{
$coma = "";
}
//
if ($segundos>0){
if ($segundos>1){$tiempo .= ", ".$segundos." Segundos ";}else{$tiempo .= ", ".$segundos." Segundo ";}
}
return $tiempo;
}
function UptimeInSeconds($uptime) {
//
$mark1=strpos($uptime, "w");
$weeks=substr($uptime, 0, $mark1);
if ($mark1) $uptime=substr($uptime, $mark1 + 1);
//
$mark1=strpos($uptime, "d");
$days=substr($uptime, 0, $mark1);
if ($mark1) $uptime=substr($uptime, $mark1 + 1);
//
$mark1=strpos($uptime, "h");
$hours=substr($uptime, 0, $mark1);
if ($mark1) $uptime=substr($uptime, $mark1 + 1);
$mark1=strpos($uptime, "m");
$minutes=substr($uptime, 0, $mark1);
if ($mark1) $uptime=substr($uptime, $mark1 + 1);
$mark1=strpos($uptime, "s");
$seconds=substr($uptime, 0, $mark1);
if ($mark1) $uptime=substr($uptime, $mark1 + 1);
$total=($weeks * 604800) + ($days * 86400) + ($hours * 3600) + ($minutes * 60) + $seconds;
return secondsToTime($total);
}