note 68792 added to function.strptime
| From: | DT | Date: | Thu, 10 Aug 2006 19:55:11 +0000 |
| Subject: | note 68792 added to function.strptime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-115775@lists.php.net to get a copy of this message | ||
//This turns non-standard but often used "datetime" string
//like '20060810084251' into nice formatted date
//'Thursday, 10 August 2006 08:42:51 CEST'
//note, that strptime returns day of year counting from 0, so
//you need to put 1 as month number to get appropriate
//month for the daycount. for 2006 strptime for unknown
//reason returns 106, so I simply add 1900
$informat = '%Y%m%d%H%M%S';
$outformat = '%A, %d %B %Y %T %Z';
$ftime = strptime("20060810084251",$informat);
$unxTimestamp = mktime(
$ftime['tm_hour'],
$ftime['tm_min'],
$ftime['tm_sec'],
1 ,
$ftime['tm_yday'] + 1,
$ftime['tm_year'] + 1900
);
//setlocale(LC_TIME,'pl_PL');
echo strftime($outformat , $unxTimestamp );
----
Server IP: 195.136.184.34
Probable Submitter: 213.134.163.79
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.strptime.php
Edit -- https://master.php.net/note/edit/68792
Del: integrated -- https://master.php.net/note/delete/68792/integrated
Del: useless -- https://master.php.net/note/delete/68792/useless
Del: bad code -- https://master.php.net/note/delete/68792/bad+code
Del: spam -- https://master.php.net/note/delete/68792/spam
Del: non-english -- https://master.php.net/note/delete/68792/non-english
Del: in docs -- https://master.php.net/note/delete/68792/in+docs
Del: other reasons-- https://master.php.net/note/delete/68792
Reject -- https://master.php.net/note/reject/68792
Search -- https://master.php.net/manage/user-notes.php