One option would be to convert the date to the number of seconds since the UNIX epoch:
date -d "2014-12-01T21:34:03+02:00" +%s
You can then compare this integer to another date which has been processed in the same way:
(( $(date -d "2014-12-01T21:34:03+02:00" +%s) < $(date -d "2014-12-01T21:35:03+02:00" +%s) ))
The ((
))
syntax is used to create an arithmetic context as we are comparing two numbers. You could also use the more general [ ${x} -lt ${y} ]
style syntax if portability is a concern.
One advantage of doing it this way is that date
understands a variety of formats, for example
date -d "next year" +%s
. Furthermore, date
understands timezones, so it can correctly handle comparisons between pairs of dates where the timezone is different.
However, if neither of those issues concerns you, then I'd go for j.a.'s solution.