note 119716 added to mongodb-bson-utcdatetime.todatetime
| From: | zeeshanyshaikh at gmail dot com | Date: | Tue, 09 Aug 2016 14:58:04 +0000 |
| Subject: | note 119716 added to mongodb-bson-utcdatetime.todatetime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-206250@lists.php.net to get a copy of this message | ||
$tz = new DateTimeZone('Asia/Kolkata'); //Change your timezone
$date = date("Y-m-d h:i:sa"); //Current Date
$a = new MongoDB\BSON\UTCDateTime(strtotime($date)*1000);
$datetime = $a->toDateTime();
echo '<pre>';print_r($datetime);echo '</pre>';
$datetime->setTimezone($tz); //Set timezone
$time=$datetime->format(DATE_ATOM); //(example: 2005-08-15T15:52:01+00:00)
echo "<br>". $time . "<br>";
OUTPUT :
//Output of datetime object
DateTime Object
(
[date] => 2016-08-09 14:57:06.000000
[timezone_type] => 1
[timezone] => +00:00
)
//Output of time
2016-08-09T20:27:06+05:30
----
Server IP: 216.194.115.244
Probable Submitter: 203.115.125.148
----
Manual Page -- http://php.net/manual/en/mongodb-bson-utcdatetime.todatetime.php
Edit -- https://master.php.net/note/edit/119716
Del: integrated -- https://master.php.net/note/delete/119716/integrated
Del: useless -- https://master.php.net/note/delete/119716/useless
Del: bad code -- https://master.php.net/note/delete/119716/bad+code
Del: spam -- https://master.php.net/note/delete/119716/spam
Del: non-english -- https://master.php.net/note/delete/119716/non-english
Del: in docs -- https://master.php.net/note/delete/119716/in+docs
Del: other reasons-- https://master.php.net/note/delete/119716
Reject -- https://master.php.net/note/reject/119716
Search -- https://master.php.net/manage/user-notes.php