function eme_localised_date($mydate,$date_format='') { global $eme_date_format, $eme_timezone; if (empty($date_format)) $date_format = $eme_date_format; // $mydate contains the timezone, but in case it doesn't we provide it $eme_date_obj = new ExpressiveDate($mydate,$eme_timezone); // Currently in the backend, the timezone is UTC, but maybe that changes in future wp versions // so we search for the current timezone using date_default_timezone_get // Since DateTime::format doesn't respect the locale, we use date_i18n here // but date_i18n uses the WP backend timezone, so we need to account for the timezone difference // All this because we don't want to use date_default_timezone_set() and wp doesn't set the backend // timezone correctly ... $wp_date = new ExpressiveDate($eme_date_obj->getDateTime(),date_default_timezone_get()); $tz_diff=$eme_date_obj->getOffset()-$wp_date->getOffset(); $result = date_i18n($date_format, $eme_date_obj->getTimestamp()+$tz_diff); return $result; }