I'm using printImageMetadata('', false,'exifdata');
With Canon 20D, 50D, Exif DateTimeOriginal give 2006:05:24 10:08:14 With Canon 7D, it give 2010-03-12T14:04:36.00+01:00 Is it possible to have something more readable
But of course. The printImageMetadata just prints what your camera records. To get something more readable you will have to format the data yourself rather than using that function.
I would suggest that instead of checking for the camera model, check for the time format itself. I suspect that other cameras use the ISO-8601 time format as well, and it would be a pain to keep updating the script for each camera model, rather than using a RegEx or similar to identify the time format, and display it accordingly. That would be more effective, and less maintenance.
I know PHP's strftime function can format a date/time in ISO-8601 format, but am not sure if strtotime or a similar built-in function can parse it.
Just my thoughts, as a programmer (though not specifically for PHP)! :-)
Comments
.../...
echo "<table id=\"$dataid\"" . ($toggle ? " style=\"display: none;\"" : '') . ">\n";
foreach ($exif as $field => $value) {
$display = $_zp_exifvars[$field][3];
if ($display) {
$label = $_zp_exifvars[$field][2];
echo "<tr><td class=\"label\">$label:</td><td class=\"value\">";
if ($field == "EXIFModel") $apn = $value;
if ($field == "EXIFDateTimeOriginal") $value = exif_date($value, $apn);
printEditable('image', $field, $editable, $editclass, $messageIfEmpty, false, $value);
echo "</td></tr>\n";
}
}
echo "</table>\n</div>\n";
.../...
function exif_date($date,$apn) {
//'Model' => string 'Canon EOS 50D' (length=13)
//50D: 'DateTimeOriginal' => string '2009:12:05 12:42:33' (length=19)
//'Model' => string 'Canon EOS 7D' (length=12)
//7D: DateTimeOriginal' => string '2010-02-20T15:07:05.24+01:00' (length=28)
// -> 50D
if (!preg_match("/7D/", $apn)) {
$pieces = explode(' ', $date);
list($yy, $mm, $dd) = explode(':', $pieces[0]);
list($hh, $min, $ss) = explode(':', $pieces[1]);
}
// 7D
else {
$pieces = explode('T', $date);
list($yy, $mm, $dd) = explode('-', $pieces[0]);
$pieces_h = explode('.', $pieces[1]);
list($hh, $min, $ss) = explode(':', $pieces_h[0]);
}
$timestamp = mktime((int) $hh, (int) $min, (int) $ss, (int) $mm, (int) $dd, (int) $yy, '-1');
$date = date('d.m.Y Ã H:i',$timestamp);
return $date;
}
I know PHP's strftime function can format a date/time in ISO-8601 format, but am not sure if strtotime or a similar built-in function can parse it.
Just my thoughts, as a programmer (though not specifically for PHP)! :-)
I didn't know the strtotime function.