How to convert PT time to time format in php?
This post convert PT time to time format in php.
1. Code:
<?php function convertTimePTToTimeFormat($timePt){ $timePt = str_replace("PT", "", $timePt); $arrTime = explode("H", $timePt); $h = $arrTime[0]; $m = str_replace("M", "", $arrTime[1]); if(!isset($h) || trim($h) === ''){ $h = "00"; } if(!isset($m) || trim($m) === ''){ $m = "00"; } return $h . ":" . $m . ":00"; } $timeD = "PT17H30M"; $str = convertTimePTToTimeFormat($timeD); ?>
2. Example:
Input:
PT17H30M
Output:
17:30:00