Preserving time zone in -FilecCreateDate<CreateDate

Started by GS, August 06, 2024, 06:36:34 PM

Previous topic - Next topic

GS

Hi,

I am trying to reset the file create date for pics I took while traveling overseas. I use -FileCreateDate<CreateDate to copy the date and time from the image meta data to the file (in Windows) and this works but loses the time zone in the process.

For example, my picture was taken at 2024:07:20 14:11:20.897+01:00. My file gets a create date of 2024:07:20 14:11:20 but my local machine's time zone is EDT (-04:00) so this is 5 hours off from when the picture was actually taken. Is there a way to preserve the time zone (from the research I've done Windows stores all file times in UTC, so it would appear that the time zone is simply getting lost along the way) or in lieu of that set the time to 09:11:20 which would be the -4:00 equivalent of 14:11:20+01:00?

Here's the before and after -time:all output:

Before:
File Modification Date/Time     : 2024:07:20 14:40:44-04:00
File Access Date/Time           : 2024:08:06 18:11:24-04:00
File Creation Date/Time         : 2024:08:06 18:11:24-04:00
Modify Date                     : 2024:07:20 14:11:20
Date/Time Original              : 2024:07:20 14:11:20
Create Date                     : 2024:07:20 14:11:20
Offset Time                     : +01:00
Offset Time Original            : +01:00
Offset Time Digitized           : +01:00
Sub Sec Time Original           : 897
Sub Sec Time Digitized          : 897
GPS Time Stamp                  : 13:11:18.69
GPS Date Stamp                  : 2024:07:20
Profile Date Time               : 2022:01:01 00:00:00
Create Date                     : 2024:07:20 14:11:20.897+01:00
Date/Time Original              : 2024:07:20 14:11:20.897+01:00
Modify Date                     : 2024:07:20 14:11:20+01:00
GPS Date/Time                   : 2024:07:20 13:11:18.69Z


After:
File Modification Date/Time     : 2024:07:20 14:40:44-04:00
File Access Date/Time           : 2024:08:06 18:11:24-04:00
File Creation Date/Time         : 2024:07:20 14:11:20-04:00
Modify Date                     : 2024:07:20 14:11:20
Date/Time Original              : 2024:07:20 14:11:20
Create Date                     : 2024:07:20 14:11:20
Offset Time                     : +01:00
Offset Time Original            : +01:00
Offset Time Digitized           : +01:00
Sub Sec Time Original           : 897
Sub Sec Time Digitized          : 897
GPS Time Stamp                  : 13:11:18.69
GPS Date Stamp                  : 2024:07:20
Profile Date Time               : 2022:01:01 00:00:00
Create Date                     : 2024:07:20 14:11:20.897+01:00
Date/Time Original              : 2024:07:20 14:11:20.897+01:00
Modify Date                     : 2024:07:20 14:11:20+01:00
GPS Date/Time                   : 2024:07:20 13:11:18.69Z

StarGeek

Quote from: GS on August 06, 2024, 06:36:34 PMIs there a way to preserve the time zone (from the research I've done Windows stores all file times in UTC, so it would appear that the time zone is simply getting lost along the way) or in lieu of that set the time to 09:11:20 which would be the -4:00 equivalent of 14:11:20+01:00?

You can't force the file system to show a +01:00 time zone. It will always be the adjusted local time.

If you look further down your output, you can see there is a create date that includes the time zone. If you copy that into the FileCreateDate, then the OS will automatically adjust the to the correct local time.

This is where FAQ #3 comes in. You would use the command listed there while keeping the -Time:All. That will show you the actual name of the tag you want to copy from, which will be SubSecCreateDate.

Alternatively, because your file has the correct GPS time stamp (GPSDateTime, which is also UTC), you can copy that directly to the FileCreateDate. The Z at the end of that indicates that it is UTC and that will make sure things are automatically adjusted.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

wywh

You can force exiftool to edit and display a different time zone than your computer is set to, but in the example below macOS Finder still converts file creation and modification file time 2001:06:01 12:00:00 to my computer time zone +02:00 +DST +01:00 +New_York +04:00 as 2001:06:01 19:00:00:

exiftool -overwrite_original -api QuickTimeUTC=1 -api TimeZone=America/New_York '-AllDates=2001:06:01 12:00:00' '-Keys:CreationDate=2001:06:01 12:00:00' '-FileCreateDate=2001:06:01 12:00:00' '-FileModifyDate=2001:06:01 12:00:00' movie.mp4

exiftool -a -G1 -s -api QuickTimeUTC=1 -api TimeZone=America/New_York -QuickTime:CreateDate -Keys:CreationDate -FileCreateDate -FileModifyDate movie.mp4
[QuickTime]     CreateDate                      : 2001:06:01 12:00:00-04:00
[Keys]          CreationDate                    : 2001:06:01 12:00:00-04:00
[MacOS]         FileCreateDate                  : 2001:06:01 12:00:00-04:00
[System]        FileModifyDate                  : 2001:06:01 12:00:00-04:00

Without -api TimeZone=America/New_York it exiftool displays it as:

exiftool -a -G1 -s -api QuickTimeUTC=1 -QuickTime:CreateDate -Keys:CreationDate -FileCreateDate -FileModifyDate movie.mp4
[QuickTime]     CreateDate                      : 2001:06:01 19:00:00+03:00
[Keys]          CreationDate                    : 2001:06:01 12:00:00-04:00
[MacOS]         FileCreateDate                  : 2001:06:01 19:00:00+03:00
[System]        FileModifyDate                  : 2001:06:01 19:00:00+03:00

- Matti

GS

-FileCreateDate<SubSecCreateDate did the trick. Thanks StarGeek!

Phil Harvey

BTW.  The API TimeZone option should work in Windows too as of version 12.84

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).