here you go: do whatever with it 🙂
<?php
function parse_tstamp($int_tstamp, $str_format)
{
// make sure the timestamp is entered & is 14 characters...
if ( !isset($int_tstamp) ) { return ('false'); }
if (strlen($int_tstamp) < 14) { return ('false'); }
// create the date...
$day = substr($int_tstamp, 6, 2);
$month = substr($int_tstamp, 4, 2);
$year = substr($int_tstamp, 0, 4);
$hour = substr($int_tstamp, 8, 2);
$min = substr($int_tstamp, 10, 2);
$sec = substr($int_tstamp, 12);
$ampm = 'pm';
// create the month & day...
if ($month == 1) { $month = 'January'; }
elseif ($month == 2) { $month = 'February'; }
elseif ($month == 3) { $month = 'March'; }
elseif ($month == 4) { $month = 'April'; }
elseif ($month == 5) { $month = 'May'; }
elseif ($month == 6) { $month = 'June'; }
elseif ($month == 7) { $month = 'July'; }
elseif ($month == 8) { $month = 'August'; }
elseif ($month == 9) { $month = 'September'; }
elseif ($month == 10) { $month = 'October'; }
elseif ($month == 11) { $month = 'November'; }
elseif ($month == 12) { $month = 'December'; }
// create the day...
if ($day < 10 && substr($day, 0, 1) != '0') { $day = '0' . $day; }
// create the 3 time-parts...
if ($hour < 10 && substr($hour, 0, 1) != '0') { $hour = '0' . $hour; }
if ($hour < 12 || $hour == 24) { $ampm = 'am'; }
if ($hour > 12) { $hour = ($hour - 12); }
if ($min < 10 && substr($min, 0, 1) != '0') { $min = '0' . $min; }
if ($sec < 10 && substr($sec, 0, 1) != '0') { $sec = '0' . $sec; }
// return it in the specified format...
$timestamp = sprintf($str_format, $day, $month, $year, $hour, $min, $sec, $ampm);
return ($timestamp);
}
$tstamp = '20030124201829';
$format = "The date is %2\$s %1\$d, %3\$d & the time is %4\$d:%5\$d:%6\$d%7\$s.";
echo parse_tstamp($tstamp, $format);
?>
returns
The date is January 24, 2003 & the time is 8:18:29pm.