0

I am having one date

2014-01-23T05:16:45.050Z

I am converting this time in to Y-m-d H:i:s format.

date("Y-m-d H:i:s", strtotime($this->headerStart));

now I want to convert time zone into previous one(2014-01-23T05:16:45.050Z). how to do that?

2 Answers 2

1

function date is already including timezone shift. Timezone information by default situated in php.ini But you can change it by date_default_timezone_set function:

$str = '2014-01-23T05:16:45.050Z';
$parsed = strtotime($str);

echo date("r", $parsed), "\n"; // Thu, 23 Jan 2014 07:16:45 +0200
date_default_timezone_set('America/New_York');
echo date("r", $parsed), "\n"; // Thu, 23 Jan 2014 00:16:45 -0500
0

Use this it will work.

date("Y-m-d", your timezone) . ."T".date("H:i:s", your timezone)."Z";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.