Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert PDT time format to this format `2016-09-13 08:56:55 +0000` - using PHP?

This string 2016-09-13 08:56:55 +0000 - What is the time zone?

How do convert PDT time format Wed Oct 12 14:40:50 PDT 2016 to this foramt 2016-09-13 08:56:55 +0000.

I am try:

$input_datetime = 'Wed Oct 12 14:40:50 PDT 2016';
$result_datetime = date('Y-m-d H:i:s',strtotime($input_datetime)) . ' +0000';
echo $result_datetime; // 2016-10-12 14:40:50 +0000

I don't know about timezones. Just I'm making the datetime format. Please update the solutions or suggest. Thanks for every one!

like image 286
Ramalingam Perumal Avatar asked Dec 31 '25 15:12

Ramalingam Perumal


1 Answers

Your expected output does not make sense to me, because line nogad mentioned, the seconds and minutes change. Please clarify. Meanwhile here the conversion format you wanted:

$datestr = 'Wed Oct 12 14:40:50 PDT 2016';
$dt = new DateTime($datestr);
echo $dt->format("Y-m-d\ H:i:s O");

Output is:

2016-10-12 14:40:50 -0700
like image 110
Philipp Palmtag Avatar answered Jan 03 '26 04:01

Philipp Palmtag



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!