View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Marcin Owsiany > Image-EXIF-DateTime-Parser-1.2 > Image::EXIF::DateTime::Parser



Annotate this POD

View/Report Bugs
Module Version: 1.2   Source  


Image::EXIF::DateTime::Parser - parser for EXIF date/time strings


  use Image::EXIF::DateTime::Parser;

  my $parser = Image::EXIF::DateTime::Parser->new;
  printf "%d\n", $p->parse("2009:05:05 09:17:37");

    produces "1241540257", if you are in America/Los_Angeles timezone.


While parsing standards-compliant EXIF Date/Time string is easy, allowing for the various ways different non-standards-compliant implementations mangle these strings is neither easy nor pleasant. This module encapsulates this complexity for you. It provides a parser which takes an EXIF Date/Time string and returns time in "calendar time" format, aka. time_t.




$p = Image::EXIF::DateTime::Parser->new

Returns a new parser object.

Introduced in version 1.1.

$time_t = $p->parse( '2009:05:05 09:17:37' )

Takes a single argument: an EXIF Date/Time string, and returns a time_t value by interpreting the string as local time.

Returns undef when the string represents an unknown date/time (zeros or blanks).

Throws an exception if the string is not parseable.

Introduced in version 1.1.


The module untaints the input string and passes the numbers (and spaces in some cases) as arguments to POSIX::mktime. Thus as long as mktime can deal with numbers and/or spaces on its input, the worst that can happen is that an invalid date/time string will produce a surprising calendar time value or an undef.


Non-canonical time strings

Because it uses POSIX::mktime, this module can accept theoretically invalid field values (such as 32nd day of month) and canonicalize them by appropriately changing other field values.


The parser currently ignores the timezone information and treats the string as date/time in the timezone it currently runs in. Please note that the EXIF standard actually forbids including timezone information the Date/Time string.

Invalid formats

This module tries to understand some common non-standards-compliant EXIF Date/Time strings, but naturally it is not possible to allow for all present and future ways that implementations can choose to mangle them. If you encounter a string that is not recognized, but could be, please report it and I will try to add it in the next version.


Marcin Owsiany <>


Image::Info(3), Image::ExifTool(3)


This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

syntax highlighting: