XF 2.1 Convert date time to proper timezone

sajal

Active member
I was using following to convert post date time to custom format in 1.5:

XenForo_Locale::getFormattedDate($post['post_date'], 'Y-m-d\TH:i:s\Z', $language, 'UTC');

I didn't find any helper to replace this code in XF 2.1, so I end up using following.

$post_date = new \DateTime('@'.$post['post_date']);
$ut_content_datetime = $post_date->format('Y-m-d\TH:i:s\Z');

But it has issues, since it is not taking the timezone into considerations and always display UTC time.

Any thoughts from experts, thanks!
 
Back
Top Bottom