note 43983 deleted from function.strtotime by aidan

From: Date: Wed, 11 Aug 2004 18:24:24 +0000
Subject: note 43983 deleted from function.strtotime by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-74494@lists.php.net to get a copy of this message
Note Submitter: http alexandre dot alapetite dot net ---- For versions of PHP that does not integrate that natively, here is a function to transform a W3C date format (subset of ISO-8601) into a UNIX timestamp: <?php function dateW3cToUnix($w3cDT) {//http://www.w3.org/TR/NOTE-datetime //1997-07-28T19:25:30.45+01:00 if (strcasecmp('Z',substr($w3cDT,-1,1))==0) { $tzd='+00:00'; $myDate=substr($w3cDT,0,-1); } else { $i=strrpos($w3cDT,'+'); if ($i<1) $i=strrpos($w3cDT,'-'); if (($i>15)&&(strlen($w3cDT)==($i+6))) { $tzd=substr($w3cDT,-6); $myDate=substr($w3cDT,0,-6); } else { $tzd='+00:00'; $myDate=substr($w3cDT,0,10); } } $lns=strlen($myDate); $year=($lns>=4)?substr($myDate,0,4):1970; $month=($lns>=7)?substr($myDate,5,2):1; $day=($lns>=10)?substr($myDate,8,2):1; $hour=($lns>=13)?substr($myDate,11,2):0; $minute=($lns>=16)?substr($myDate,14,2):0; $second=($lns>=19)?substr($myDate,17,2):0; $sign=($tzd[0]=='+')?-1:1; $tzdHour=substr($tzd,1,2); $tzdMinute=substr($tzd,-2); $hour+=($tzdHour*$sign); $minute+=($tzdMinute*$sign); return gmmktime($hour,$minute,$second,$month,$day,$year); } ?>

« previous php.notes (#74494) next »