Skip to content

Instantly share code, notes, and snippets.

@niczak
Created February 24, 2011 01:02
Show Gist options
  • Save niczak/841548 to your computer and use it in GitHub Desktop.
Save niczak/841548 to your computer and use it in GitHub Desktop.
Convert PostgreSQL timestamp to human readable date.
<?php
// Convert PostgreSQL timestamp to human readable date
function fnDisplay_Timestamp($sDT)
{
// Assuming $sDT is in format: YYYY-MM-DD HH:MM:SS.MS
if(empty($sDT))
fnErr("No parameter passed to fnDisplay_Timestamp() function.");
$aDT = explode(' ', $sDT);
if(count($aDT) != 2)
fnErr("Invalid parameter passed to fnDisplay_Timestamp() function.");
$sDate = $aDT[0];
$sDate = substr($sDate, 5, 2).'/'.substr($sDate, 8, 2).'/'.substr($sDate, 0, 4);
return $sDate;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment