Saturday, 10 September 2016

How to change the date format of other timezone which is not the current timezone?

Change the default timezone to the required timezone.
Then, convert the date format by using strtotime() and date() functions.
And at last, change the default timezone to the earlier one.

$defaultTimeZone = date_default_timezone_get(); // Taking default timezone
date_default_timezone_set('EST'); // Setting EST as default timezone
echo date('m/j/Y G:i',strtotime('2011-10-05 16:35:49.917'))."<br/>";

No comments:

Post a Comment

Your comment is so valuable as it would help me in my growth of knowledge.