note 80304 deleted from function.strtotime by bjori
| From: | bjori@php.net | Date: | Wed, 09 Jan 2008 17:32:28 +0000 |
| Subject: | note 80304 deleted from function.strtotime by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-134974@lists.php.net to get a copy of this message | ||
Note Submitter: tomasz dot slominski at gmail dot com
Reason: useless
----
Simple date format converter with input order
<?php
function formatSQLDateTime($sDate = null, $sOrder = 'dmyhis'){
if ($sDate == null){
return date("Y-m-d H:i:s");
} else {
$aOrder = str_split($sOrder);
$aResult = preg_split('/[^\d]/',$sDate);
$nCount = count($aResult);
if ($nCount<6){
$aResult = $aResult + array_fill($nCount,6-$nCount,'00');
} // if
$aResult = array_combine($aOrder,$aResult);
return ("$aResult[y]-$aResult[m]-$aResult[d] $aResult[h]:$aResult[i]:$aResult[s]");
} // if
} // function
?>