Timezone indication

Started by Tezlacore, May 15, 2023, 02:57:32 PM

Previous topic - Next topic

Tezlacore

Hi all!

Another timezone question here. On some of my videos I'm struggling to get the timezoning correctly done.

What I'm trying to do is first set the tag "Keys:CreationTime" to the value listen in the corresponding JSON file, under "photoTakenTime" --> "Timestamp" (which is in UTC time). After that, I want to set the file create and file modify date. However, if a video is shot abroad, I want this to be displayed in the "Keys:CreationTime" by displaying the "+07:00". Currently, the system automatically sets it at +01:00 or +02:00 (depending on date and daylight saving I suppose?). How would I go about manually adjusting the timezone indication?

C:\exiftool.exe -d %s -tagsfromfile "$jsonfilepath\%F.json" '-Keys:CreationDate<PhotoTakenTimeTimestamp' -overwrite_original -Progress -ext MOV -ext MP4 $targetfolder
C:\exiftool.exe '-FileCreateDate<CreationDate' '-FileModifyDate<CreationDate' -overwrite_original -Progress -m -ext MOV -ext MP4 $targetfolder

StarGeek

#1
The default time zone will be the time zone that the computer is currently set to.  It will adjust to Daylight savings automatically depending upon the date.

Do you want to set the time zone to +07:00 and not account for Daylight savings?  Or does it need to adjust?

Do you want to adjust the CreationDate to the correct time based upon the time zone?  For example, if the time stamp was 2023:05:15 12:00:00+00:00 (noon UTC), do you want to write 2023:05:15 19:00:00+07:00?

Still thinking on this.  On linux/mac, it would be easier to due because of the -api TimeZone option.  But Windows, it's more complicated, as it doesn't have a nice, easy way to change the time zone temporarily.  It has the _tzset command, but it does not work in an intelligent manner and you would have to do the math manually to set the time correctly.  See this post where I tried to figure out the _tzset command
* 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).

StarGeek

There really is no easy way to do this on Windows. I dug through a lot of Perl commands having to do with time zones and they pretty much all require the Perl DateTime module, which isn't included in exiftool.  So you have to manually set the time zone values.

Assuming CMD, try
exiftool.exe -tagsfromfile "$jsonfilepath\%F.json" "-Keys:CreationDate<${PhotoTakenTimeTimestamp;$_=ConvertUnixTime($_);ShiftTime('7')}+07:00" /path/to/files/

The PhotoTakenTimeTimestamp is in Unix time. ConvertUnixTime converts that a human readable date/time.  But this is in UTC, so it needs to be changed to the target time.  ShiftTime will add 7 hours.  Then you place the time zone at the end.  Change the 7 in ShiftTime('7')}+07:00 to the target timezone.

Take note that the -d %s isn't needed, as ConvertUnixTime has taken over that conversion.

Example.  Here I use Description instead of the json file's PhotoTakenTimeTimestamp, but the process is the same.

First, list the starting values. The value of 1684152000 epoch is equal to "2023:05:15 12:00:00" UTC
C:\>exiftool -G1 -a -s -Description -CreateDate -CreationDate Y:\!temp\aa\Test.mp4
[ItemList]      Description                     : 1684152000
[QuickTime]     CreateDate                      : 0000:00:00 00:00:00

Copy the Description value directly to the CreateDate and list again. CreateDate shows the correct time in UTC
C:\>exiftool -P -overwrite_original -d %s "-Quicktime:CreateDate<Description" Y:\!temp\aa\Test.mp4
    1 image files updated

C:\>exiftool -G1 -a -s -Description -CreateDate -CreationDate Y:\!temp\aa\Test.mp4
[ItemList]      Description                     : 1684152000
[QuickTime]     CreateDate                      : 2023:05:15 12:00:00

Now, do the conversion and shift and copy to CreationDate.  Results show the correct time shifted to a +07:00 time zone.
C:\>exiftool -P -overwrite_original "-Quicktime:CreationDate<${Description;$_=ConvertUnixTime($_);ShiftTime('7')}+07:00" Y:\!temp\aa\Test.mp4
    1 image files updated

C:\>exiftool -G1 -a -s -Description -CreateDate -CreationDate Y:\!temp\aa\Test.mp4
[ItemList]      Description                     : 1684152000
[QuickTime]     CreateDate                      : 2023:05:15 12:00:00
[Keys]          CreationDate                    : 2023:05:15 19:00:00+07:00
* 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).

Tezlacore

Brilliant, thanks for the quick reply(ies)!

Quote from: StarGeek on May 15, 2023, 07:22:34 PMexiftool.exe -tagsfromfile "$jsonfilepath\%F.json" "-Keys:CreationDate<${PhotoTakenTimeTimestamp;$_=ConvertUnixTime($_);ShiftTime('7')}+07:00" /path/to/files/

Not sure if it's because I'm working in Powershell rather than CMD, but had to change the quotation signs to work:

C:\exiftool.exe -tagsfromfile "$jsonfilepath\%F.json" '-Keys:CreationDate<${PhotoTakenTimeTimestamp;$_=ConvertUnixTime($_);ShiftTime("7")}+07:00' /path/to/files/

Tezlacore

Hmm, something doesn't seem right still. I've got a folder with some video files in there that don't have the Keys:CreationDate tag in their metadata. When I try to set it based on the piece of code we discussed above, Powershell gives me the feedback: "Warning: No writable tags set from FILENAME"

Any idea why this may be? I ran the same code writing to the "Description" tag instead, and this does get written (see attachment), so the tag does exist in the JSON.

StarGeek

Quote from: Tezlacore on May 16, 2023, 08:14:02 AMNot sure if it's because I'm working in Powershell rather than CMD, but had to change the quotation signs to work:

Yes, you have to pay attention to the highlighting in PS.  Each argument should be the same color, not like this


Powershell isn't the best for exiftool.  There are other standard exiftool commands that work in CMD, Mac, and Linux that don't work in PS.  For example, you can't extract thumbnails or other embedded images with PS.

Quote from: Tezlacore on May 16, 2023, 11:02:12 AMWhen I try to set it based on the piece of code we discussed above, Powershell gives me the feedback: "Warning: No writable tags set from FILENAME"

Any idea why this may be? I ran the same code writing to the "Description" tag instead, and this does get written (see attachment), so the tag does exist in the JSON.

I can't really comment without seeing the exact command and output.

Check the highlighting and make sure it is solid. Or try CMD.  Also, run exiftool on the json file to make sure of the tag names with the command in FAQ #3.
* 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).

Tezlacore

Problem seems to be solved.

I think the issue was that I had the "-d %s" still in the code (because I was running some other tags too in the same command that needed the formatting) which caused issues setting the CreationDate tag in the correct format.

Thanks for the help!