note 109475 added to class.datetime

From: Date: Fri, 20 Jul 2012 09:28:11 +0000
Subject: note 109475 added to class.datetime
Groups: php.notes 
Request: Send a blank email to php-notes+get-189311@lists.php.net to get a copy of this message
DateTime extension that work with millisecond class MilliSecondDateTime extends Datetime{ private $millisecond; public function __construct($time = NULL,$time_zone = NULL){ if(is_null($time)) $time = '@'.microtime(true); if(is_null($time_zone)) $time_zone = new DateTimeZone('UTC'); if(preg_match('/@(\d+)\.(\d+)/',$time,$matches)){ $this->millisecond = $matches[2]; parent::__construct('@'.$matches[1],$time_zone); } else { $this->millisecond = 0; parent::__construct($time,$time_zone); } } public function getSQLDate(){ return $this->format('Y-m-d G:i:s').'.'.$this->millisecond; } } Note that sub() method continue to work with millisecond ---- Server IP: 69.147.83.197 Probable Submitter: 193.251.181.84 ---- Manual Page -- http://www.php.net/manual/en/class.datetime.php Edit -- https://master.php.net/note/edit/109475 Del: integrated -- https://master.php.net/note/delete/109475/integrated Del: useless -- https://master.php.net/note/delete/109475/useless Del: bad code -- https://master.php.net/note/delete/109475/bad+code Del: spam -- https://master.php.net/note/delete/109475/spam Del: non-english -- https://master.php.net/note/delete/109475/non-english Del: in docs -- https://master.php.net/note/delete/109475/in+docs Del: other reasons-- https://master.php.net/note/delete/109475 Reject -- https://master.php.net/note/reject/109475 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#189311) next »