note 68792 modified in function.strptime by danbrown

From: Date: Sun, 20 Jul 2008 03:50:20 +0000
Subject: note 68792 modified in function.strptime by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-142094@lists.php.net to get a copy of this message
<?php //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 ); ?> --was-- //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 ); http://php.net/manual/en/function.strptime.php

« previous php.notes (#142094) next »