note 107839 added to function.strtotime

From: Date: Thu, 08 Mar 2012 22:13:59 +0000
Subject: note 107839 added to function.strtotime
Groups: php.notes 
Request: Send a blank email to php-notes+get-186549@lists.php.net to get a copy of this message
I was doing work with cisco phone systems, and thy record their times as NTP Format. strtotime() doesnt process the whole NTP timestamp, off the bat, so if you want a quick function to work I bashed this together pretty quickly, there are probably more efficent ways of processing this, but it gets the job done. Enjoy. [code] <?php //Note: I ran this in PHP 5.3.x function NTPtoUnixtime($ntptime) { $explodedNTPtime = explode(" ", $ntptime,2); $startOfDay = strtotime("Today"); $timeThroughDay = strtotime($explodedNTPtime[0]) - $startOfDay ; return strtotime($explodedNTPtime[1])+$timeThroughDay; } $ntpTime = "09:49:22.897 NZDT Mon Feb 20 2012"; //NTP time to convert. echo NTPtoUnixtime($ntpTime); //produces: 1329684562 // Which equates to: Mon 20 Feb 2012 09:49:22 NZDT GMT+13 ?> [/code] ---- Server IP: 69.147.83.197 Probable Submitter: 120.136.7.60 ---- Manual Page -- http://www.php.net/manual/en/function.strtotime.php Edit -- https://master.php.net/note/edit/107839 Del: integrated -- https://master.php.net/note/delete/107839/integrated Del: useless -- https://master.php.net/note/delete/107839/useless Del: bad code -- https://master.php.net/note/delete/107839/bad+code Del: spam -- https://master.php.net/note/delete/107839/spam Del: non-english -- https://master.php.net/note/delete/107839/non-english Del: in docs -- https://master.php.net/note/delete/107839/in+docs Del: other reasons-- https://master.php.net/note/delete/107839 Reject -- https://master.php.net/note/reject/107839 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#186549) next »