Solved: Camera was set to wrong time - any way to fix in post?

DT5. Windows. Sony RAW+JPEG pairs and my phone.

I traveled to a different time zone. I was taking pictures with both my camera and phone.
My pictures are sorted by capture time, they are in the wrong order. My phone adjusted to the correct time zone, but I forgot to change my camera time settings before shooting.

I don’t see a way to correct the datetime in the metadata editor. The image information panel is un-editable.

Is there an external program on Windows (or linux) I could use to adjust the time and get DT to re-read the correct time? I’d want it to read the time, add an offset (e.g. 2 hours), then write that back. It’s several hundred photos that internally have the wrong time.

You should be able to do that with ExifTool, and maybe also with Exiv2. The usual cautions about modifying your raw files apply. Take backups first.

What elGordo said - but there is more than one date/time to consider in Exif:

0x9003 DateTimeOriginal
0x9004 CreateDate
0x0132 ModifyDate

0x0132 might not be in your raws but is probably in your JPEGs.

I don’t know which one(s) dt uses …

I hope you are familiar with command-line stuff so you can do the two-hour offset thing …

… otherwise, this might be of interest:

Also, you may want to re-import your files after changing the EXIF info. For the changed files, you’ll have an inconsistency between the database (and possible sidecars) and the image files. Re-importing corrects that, and makes the new times visible to darktable. (I don’t think darktable scans for changes in image files on startup)

It is pretty simple with the command line tool exiftool
Try this:
Check meta data for key word ‘Date’

exiftool -s L1008985.DNG | grep Date

It gives you a few lines with various dates:

FileModifyDate                  : 2024:12:17 13:19:15+01:00
FileAccessDate                  : 2024:12:26 08:41:12+01:00
FileInodeChangeDate             : 2024:12:26 08:38:40+01:00
ModifyDate                      : 2024:12:17 13:19:15
CreateDate                      : 2024:12:17 13:19:15
DateTimeOriginal                : 2024:12:17 13:19:15

Then change ‘DateTimeOriginal’ and ‘CreateDate’:

exiftool '-datetimeoriginal=2025:01:18 12:00:00' L1008985.DNG
exiftool '-CreateDate=2025:01:18 12:00:00' L1008985.DNG

Check the meta data for key word ‘Date’ again:

exiftool -s L1008985.DNG | grep Date
FileModifyDate                  : 2024:12:26 08:46:56+01:00
FileAccessDate                  : 2024:12:26 08:46:57+01:00
FileInodeChangeDate             : 2024:12:26 08:46:56+01:00
ModifyDate                      : 2024:12:17 13:19:15
DateTimeOriginal                : 2025:01:18 12:00:00
CreateDate                      : 2025:01:18 12:00:00

Et voilà.

1 Like

Doing it on windows and adding an offset to the existing time might be a little bit more complicated though…

This post on the Exiftool forum might be useful to do what OP wants.

Of course, backup and test on a small sample before attacking all the images that need changing…

1 Like

Thanks @rvietor, this worked.

My camera was 1 hour ahead. Below command subtracted 1 hour in all the Sony ARW and JPG, leaving my phone’s pictures un-touched. I had the DT XMP in the folder, too, and it just ignored them.

exiftool -alldates-=1 -overwrite_original DSC*.*

Removing and re-importing, the darktable datetime values showed the change. Both the ARW and JPG showed the corrected time. All of my photos were GPS tagged. I was able to check them in map view. The photo order is now correct in time and space.

Internal to the image files, some of the metadata is inconsistent. The use of the “alldates” tag was good enough for what darktable needed without needing to fix ALL of the time tags individually.

Before

After

You could also have used the image_time lua-script which would have updated the times in the database and not messed with the original images.

Well done! Another case solved by the crew.