Reputation: 95
Using the following code I'm getting the output as mentioned below.
echo $date = new date('c', strtotime('2017-03-14T22:30:00.000Z'));
Current Output: 2017-03-15T04:30:00+06:00
Expected Output: 2017-03-15 10:30:00 AM
How could I do it using PHP?
Upvotes: 1
Views: 45
Reputation: 13087
I would suggest to use DateTime
$d = new DateTime('2017-03-14T22:30:00.000Z');
echo $d->format('Y-m-d H:m:s');
//2017-03-14 22:03:00
$d->setTimezone(new DateTimeZone('Asia/Dhaka'));
echo $d->format('Y-m-d H:m:s');
//2017-03-15 04:03:00
Also, it seems to me that Asia/Dhaka is in fact UTC+6 so what you are after would be 2017-03-15T04:30:00
, not 2017-03-15T10:30:00
(here the offset would be 12 hours)?
Upvotes: 0
Reputation: 1667
Please try this:
echo $date = date('Y-m-d H:i:s A', strtotime('2017-03-14T22:30:00.000Z'));
Upvotes: 1