note 82004 added to function.strptime
| From: | firefox3107 at gmail dot com | Date: | Mon, 24 Mar 2008 02:44:18 +0000 |
| Subject: | note 82004 added to function.strptime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-137450@lists.php.net to get a copy of this message | ||
For Windows user! It's rather the same as strptime!
It uses the previous function: but call strToTime($date, $format) to strToDate($date, $format)
because this name is forgiven!
<?php
function strToDateTime($date, $format) {
if(!($date = strToDate($date, $format))) return;
$dateTime = array('sec' => 0, 'min' => 0, 'hour' => 0,
'day' => 0, 'mon' => 0, 'year' => 0, 'timestamp'
=> 0);
foreach($date as $key => $val) {
switch($key) {
case 'd':
case 'j': $dateTime['day'] = intval($val); break;
case 'D': $dateTime['day'] = intval(date('j', $val)); break;
case 'm':
case 'n': $dateTime['mon'] = intval($val); break;
case 'M': $dateTime['mon'] = intval(date('n', $val)); break;
case 'Y': $dateTime['year'] = intval($val); break;
case 'y': $dateTime['year'] = intval($val)+2000; break;
case 'G':
case 'g':
case 'H':
case 'h': $dateTime['hour'] = intval($val); break;
case 'i': $dateTime['min'] = intval($val); break;
case 's': $dateTime['sec'] = intval($val); break;
}
}
$dateTime['timestamp'] = mktime($dateTime['hour'], $dateTime['min'],
$dateTime['sec'], $dateTime['mon'], $dateTime['day'],
$dateTime['year']);
return $dateTime;
}
?>
----
Server IP: 81.223.48.75
Probable Submitter: 83.181.37.202
----
Manual Page -- http://www.php.net/manual/en/function.strptime.php
Edit -- https://master.php.net/note/edit/82004
Del: integrated -- https://master.php.net/note/delete/82004/integrated
Del: useless -- https://master.php.net/note/delete/82004/useless
Del: bad code -- https://master.php.net/note/delete/82004/bad+code
Del: spam -- https://master.php.net/note/delete/82004/spam
Del: non-english -- https://master.php.net/note/delete/82004/non-english
Del: in docs -- https://master.php.net/note/delete/82004/in+docs
Del: other reasons-- https://master.php.net/note/delete/82004
Reject -- https://master.php.net/note/reject/82004
Search -- https://master.php.net/manage/user-notes.php