note 119513 added to mongodb-bson-utcdatetime.todatetime

From: Date: Mon, 27 Jun 2016 10:09:36 +0000
Subject: note 119513 added to mongodb-bson-utcdatetime.todatetime
Groups: php.notes 
Request: Send a blank email to php-notes+get-205817@lists.php.net to get a copy of this message
//convert retrieved time back to local time <?php /********************constructor**********************************/ $orig_date = new DateTime('2016-06-27 13:03:33'); $orig_date=$orig_date->getTimestamp(); $utcdatetime = new MongoDB\BSON\UTCDateTime($orig_date*1000); /********************retrieve time in UTC**********************************/ $datetime = $utcdatetime->toDateTime(); $time=$datetime->format(DATE_RSS); /********************Convert time local timezone*******************/ $dateInUTC=$time; $time = strtotime($dateInUTC.' UTC'); $dateInLocal = date("Y-m-d H:i:s", $time); echo $dateInLocal; ?> output: 2016-06-27 13:03:33 ---- Server IP: 72.52.91.14 Probable Submitter: 46.176.55.28 ---- Manual Page -- http://php.net/manual/en/mongodb-bson-utcdatetime.todatetime.php Edit -- https://master.php.net/note/edit/119513 Del: integrated -- https://master.php.net/note/delete/119513/integrated Del: useless -- https://master.php.net/note/delete/119513/useless Del: bad code -- https://master.php.net/note/delete/119513/bad+code Del: spam -- https://master.php.net/note/delete/119513/spam Del: non-english -- https://master.php.net/note/delete/119513/non-english Del: in docs -- https://master.php.net/note/delete/119513/in+docs Del: other reasons-- https://master.php.net/note/delete/119513 Reject -- https://master.php.net/note/reject/119513 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#205817) next »