Formatting exif date format

I was looking for a way to display the exif date in the european format:
day-month-year hour:minute instead of year-day-month

Since I didn't found a setting or a solution I made a little mod in the template-function.php line 2387 and below.

Original:
`
<?php
foreach ($exif as $field => $value) {
$label = $_zp_exifvars[$field][2];
echo "$label:";
echo html_encode($value);
echo "\n";
}
?>
`
modified:
`
<?php
foreach ($exif as $field => $value) {
$label = $_zp_exifvars[$field][2];
echo "$label:";
if ($field=="EXIFDateTimeOriginal" || $field=="EXIFDateTime"){
$date = new DateTime($value);
echo date_format($date, 'd/m/Y H:i:s');
}else{
echo html_encode($value);
};
echo "\n";
}
?>
`
I know that is not a good solution to modify the core files. Every update I must remember to do the same mod.
It would be nice to modify the code with a variable setting in admin (the date format 'd/m/Y H:i:s') so it would be possible to customize as needed.

Perhaps there is another "cleaner" solution. In case let me know, Thank you
Walter

Comments

  • Your code looks reasonable. Of course you need not modify the core, you can simply make your own print function under a different name by copying the code then modifying it.

    There is a define for the data format set for the site: `DATE_FORMAT`.

    Probably the cleanest solution would be to add formatting information to the `$_zp_exifvars` array and use that in the output function.
Sign In or Register to comment.