Express QT Creation Date in different time zone

Started by britsy, October 21, 2022, 02:24:39 PM

Previous topic - Next topic

britsy

Hello,

Some of my .mp4 files do not have the tag QuickTime:CreationDate filled in and I need to fix that.
To populate this value I do the following (in a .bat file):
PATH\exiftool.exe -P -overwrite_original -ext MP4 -api QuickTimeUTC "-QuickTime:CreationDate<QuickTime:CreateDate" %* -k
However, it creates the tag in the time zone of my PC that is different from the time zone I would like to express the time. I could do a follow-up entry to shift it but I was wondering if this could be achieved in a single entry.

Thanks a lot!

Phil Harvey

You could do something like this (to for example use UTC-02:00):

exiftool "-QuickTime:CreationDate<${QuickTime:CreateDate;ShiftTime('-2')}-02:00" ...

- 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 ($).

StarGeek

#2
I had to go digging but I remembered there was another way.  Something I forgot to add to my notes.

On Mac/Linux, the -api TimeZone option could be used

I don't have Mac/Linux to test, but I think this would work for CET
exiftool -api TimeZone=Europe/Amsterdam -ext MP4 -api QuickTimeUTC "-QuickTime:CreationDate<QuickTime:CreateDate" /path/to/files/
or EET
exiftool -api TimeZone=Europe/Bucharest -ext MP4 -api QuickTimeUTC "-QuickTime:CreationDate<QuickTime:CreateDate" /path/to/files/

On Windows, you would either first use (not an exiftool command)
Set TZ=Europe/Amsterdam
or
Set TZ=Europe/Bucharest

Then run your exiftool command, followed by
set TZ=

Windows example
C:\>exiftool -G1 -a -s -createdate -api QuickTimeUTC Y:\!temp\Test1.mp4
[QuickTime]    CreateDate                      : 2022:10:21 12:00:00-07:00

C:\>Set TZ=Europe/Amsterdam

C:\>exiftool -G1 -a -s -createdate -api QuickTimeUTC Y:\!temp\Test1.mp4
[QuickTime]    CreateDate                      : 2022:10:21 20:00:00+01:00

C:\>exiftool -P -overwrite_original -api QuickTimeUTC -QuickTime:CreateDate="2022:10:21 12:00:00" Y:\!temp\Test1.mp4
    1 image files updated

C:\>exiftool -G1 -a -s -createdate -api QuickTimeUTC Y:\!temp\Test1.mp4
[QuickTime]    CreateDate                      : 2022:10:21 12:00:00+01:00

C:\>set TZ=

C:\>exiftool -G1 -a -s -createdate -api QuickTimeUTC Y:\!temp\Test1.mp4
[QuickTime]    CreateDate                      : 2022:10:21 04:00:00-07:00
[/s]

Definitely adding to notes now.  And I think I have a StackExchange answer I can update with this.

On Windows, using
set TZ=CET
does not work.  Would Mac/Linux be able to use this?
-api TimeZone=CET
* 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).

Phil Harvey

Very smart!  I completely forgot about the TimeZone API option.

- 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 ($).

StarGeek

Ok, the Windows examples are incorrect.  I just assumed that the results were correct because they seemed right without actually checking.  I looks like if the TZ is anything that Windows doesn't understand, it's defaulting to +00:00/+01:00

The actual values that Windows is supposed to understand are 3 character time zone (PST,CST,EST), then the number needed to adjust the time to UTC, which is the reverse of the actual time zone.  So -08:00 time zone would be 8.  Finally, the the name of the Daylight savings if used.  See _tzset.

But the thing is, I'm don't think any of that matters except the number in the middle.  I tested Set TZ=xyz7mmm and using "2022:09:21" and "2022:12:21" to test with, I got the proper results of -06:00 and -07:00.

This is not the rabbit hole I wanted to go down today.  Bah, too much time wasted on this without any good results.
* 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).

britsy

Sorry for that StarGeek  :-\
I'm not sure if the conclusion of your assessment is that it can't be done on Windows (which is what I use) or if it's quite complicated but I've been using the initial command provided by Phil and it worked fine for my case.

Thanks to both of you.

StarGeek

Quote from: britsy on October 22, 2022, 08:21:44 PMSorry for that StarGeek  :-\

Certainly not your fault and I needed to figure it out for my own use.

QuoteI'm not sure if the conclusion of your assessment is that it can't be done on Windows

It can be done, it's just the letters don't seem to matter.  Use any three letters, add in the reverse of the time zone (-08:00 time zone becomes just 8, +05:00 time zone becomes -5), and then three more letters if you want to take Daylight savings into account.  For some of the more edge cases where they have time zones that are set on the exact hour, using the actual three character time zone name might make a difference, but I just don't care anymore.  Using something like Set TZ=abc8xyz works correctly for PST/PDT, which is all I need.

Wikipedia has a list of time zone names and any time I post on time zones I'm required to link to the Tom Scott The Problem with Time & Timezones video.  Pretty sure that's a law somewhere ;).
* 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).

britsy

Loved the video  ;D
Exactly how I feel trying to manage time zones for my photos!  ;D