code: def get_time(filename, tags):
      
      # use exif 'Image DateTime' field as the time
      if 'Image DateTime' in tags.keys():
          return time.strptime(str(tags['Image DateTime']), '%Y:%m:%d %H:%M:%S')
  
      # very fuzzy time machting on filename
      # TODO: very fuzzy part, now it just matches the iphone naming convention
      m = re.match('^(\d{4}-\d{2}-\d{2} \d{2}\.\d{2}\.\d{2}).*', filename)
      if m:
          return time.strptime(m.group(0), '%Y-%m-%d %H.%M.%S')
  
      # if all else fails use stat().st_mtime (consistent on windows/linux as last modification time)
      return time.localtime(Path(filename).stat().st_mtime)
docs: Get most reliable timestamp from a picture, running down a couple of options.
      Filename, exif tags, modification time.