6

I am developing a Web Application using PHP Laravel that involves some processing as well. What I am doing now is I am trying to extract the time taken from the image file when user uploads the file. I can extract the data using exif_read_data function like this.

$exif_data = exif_read_data($file);
echo $exif_data['DateTimeOriginal'];

When I retrieve, the format is YYYY:MM:DD H:m:s. But I also need to know the milli/nano seconds as well after seconds. So, is there a way to retrieve more precise time the photo is taken from the image file and how can I do it?

Wai Yan Hein
  • 13,651
  • 35
  • 180
  • 372
  • `microtime();` http://php.net/manual/en/function.microtime.php for the current time, unless the image has been saved with more exact time data then no – pokeybit Apr 21 '18 at 15:48
  • No, I would like to retrieve the time photo is taken from the exif/meta data of the photo. – Wai Yan Hein Apr 21 '18 at 15:56
  • Doesn't look like there is a field in the exif data that goes beyond `second`. https://www.awaresystems.be/imaging/tiff/tifftags/privateifd/exif.html – chris85 Apr 21 '18 at 16:00
  • @chris85 Thanks for the link. The document you linked to indeed mentions `SubSecTime` `SubSecTimeOriginal` `SubSecTimeDigitized`. – Stéphane Gourichon Apr 14 '19 at 06:48

1 Answers1

9

you should be able to get the millisecond/nanosecond resolution from the sub-second tags: SubsecTime, SubsecTimeOriginal or SubsecTimeDigitized, which are the array keys of the EXIF information.

michasaurus
  • 184
  • 2
  • 6
  • 1
    Thanks so much, that helped. Nice meeting u as well. – Wai Yan Hein Apr 21 '18 at 16:14
  • 2
    And that's part of the standard. https://www.dpreview.com/forums/post/21773296 mentions http://www.exif.org/Exif2-2.PDF from year 2002 which at page 24 specifies `SubSecTime` `SubSecTimeOriginal` `SubSecTimeDigitized`. – Stéphane Gourichon Apr 14 '19 at 06:47