note 101111 deleted from function.strptime by danbrown
| From: | danbrown@php.net | Date: | Fri, 26 Nov 2010 15:28:25 +0000 |
| Subject: | note 101111 deleted from function.strptime by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-174384@lists.php.net to get a copy of this message | ||
Note Submitter: remi dot poulet at elteg dot com
----
the function
function mystrToTime($date,$format) {
$array_source=array('-','.','?','d',
'D','j','l','N','S','w','z',
'W','F','m',
'M','n','t','L',
'o','Y','y','a','A','B',
'g','G','h', 'H',
'i','s','u','e','I',
'O','P','T','Z','c','r','U');
$array_dest=array('\-','\.','\?',
'([0-9]{2})','','([0-9]{1,2})','','','',
'','','','','([0-9]{2})','','([0-9]{1,2})','','',
'','([0-9]{4})','([0-9]{2})',
'','','','([0-9]{1,2})',
'([0-9]{1,2})','([0-9]{2})','([0-9]{2})',
'([0-9]{2})','([0-9]{2})','','','','','',
'','','','');
$myreg='#'.str_replace($array_source,$array_dest,$format).'#';
$mydate=array(0,0,0,0,0,0,0);
$array_final=array(6,6,6,4, 6,4,6,6,6,6,6,6,6,3,6,3,
6,6,6,5,5, 6,6,6,0,0, 0,0,1,2,6,6,6,6,6,6,6);
$myreg2=preg_match_all($myreg,$date,$matches);
$ind=0;
for ($i=0;$i<strlen($format);$i++) {
if (in_array($format{$i},$array_source)) {
for ($j=3;$j<sizeof($array_source);$j++) {
if ($format{$i}==$array_source[$j]) {
$mydate[$array_final[$j]]=$matches[$ind+1][0];
$ind++;
}
}
}
}
return mktime($mydate[0],$mydate[1],$mydate[2],
$mydate[3],$mydate[4],$mydate[5]);
}
do hardly the job (need to be improve to manage also esotheric times like z or u or B swatch time)