/** * Get the IPCT date of an image * * @global type $UNC_GALLERY * @param type $file_path * @return boolean */ function unc_ipct_date($file_path) { global $UNC_GALLERY; if ($UNC_GALLERY['debug']) { XMPP_ERROR_trace(__FUNCTION__, func_get_args()); } $ipct_obj = new IPTC($file_path); $ipct_date = $ipct_obj->get('created_date'); // '20160220', $ipct_time = $ipct_obj->get('created_time'); // '235834', if (strlen($ipct_date . $ipct_time) != 14) { if ($UNC_GALLERY['debug']) { XMPP_ERROR_trace(__FUNCTION__, "ipct length wrong: {$ipct_date} / {$ipct_time}"); } return false; } $search_pattern = '/(\\d\\d\\d\\d)(\\d\\d)(\\d\\d) (\\d\\d)(\\d\\d)(\\d\\d)/'; $replace_pattern = '$1-$2-$3 $4:$5:$6'; $fixed_date = preg_replace($search_pattern, $replace_pattern, "{$ipct_date} {$ipct_time}"); return $fixed_date; }