note 72980 added to function.strptime

From: Date: Tue, 06 Feb 2007 18:38:16 +0000
Subject: note 72980 added to function.strptime
Groups: php.notes 
Request: Send a blank email to php-notes+get-122933@lists.php.net to get a copy of this message
my function to convert a timestamp from a GPX file. If you only need the time, then you can leave the date blank (duration, etc.) But there is one confusing thing: i always have to add one month in the strf-array function convertDate($time, $date = "") { if (!strlen($date)) { $format = '%H:%M:%S'; } elseif ( is_numeric($date[3])) { // 18-Dec-06 10:29:32 $format = '%d-%m-%y %H:%M:%S'; } else { // 18-12-06 10:29:32 $format = '%d-%b-%y %H:%M:%S'; } $ts = trim($date . " " . $time); if($strf = strptime($ts, $format)) { // @todo: I don't, why i had to add 1 month .. but for the moment, its ok if (!strlen($date)) { return $strf["tm_hour"]*3600 + $strf["tm_min"] * 60 + $strf["tm_sec"]; } else { return mktime($strf["tm_hour"], $strf["tm_min"], $strf["tm_sec"], $strf["tm_mon"]+1, $strf["tm_mday"], $strf["tm_year"]); } } else { return false; } } ---- Server IP: 217.160.72.57 Probable Submitter: 194.94.79.191 ---- Manual Page -- http://www.php.net/manual/en/function.strptime.php Edit -- https://master.php.net/note/edit/72980 Del: integrated -- https://master.php.net/note/delete/72980/integrated Del: useless -- https://master.php.net/note/delete/72980/useless Del: bad code -- https://master.php.net/note/delete/72980/bad+code Del: spam -- https://master.php.net/note/delete/72980/spam Del: non-english -- https://master.php.net/note/delete/72980/non-english Del: in docs -- https://master.php.net/note/delete/72980/in+docs Del: other reasons-- https://master.php.net/note/delete/72980 Reject -- https://master.php.net/note/reject/72980 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#122933) next »