Epoch script: add 5 hours to the time

Advanced Renamer forum
#1 : 07/05-25 02:05
Ted Williams
Posts: 5
Hi everybody. I'm using an epoch script (see below) I found on this forum and I know less than nothing about creating/editing the scripts.
Can someone tell me the change that is needed to add 5 hours to the time? Thanks for your assistance.

File name: 1746299268259420
converts to: 20250503_0914
should be: 20250503_1414 (file created 5/3/2025 2:14PM)

epoch = app.parseTags("<UnixTimestamp Modified>");
dat = new Date(1000 * epoch);
return dat.getFullYear().toString()
+ ("0" + (dat.getMonth() + 1)).slice(-2)
+ ("0" + dat.getDate()).slice(-2)
+ "_" + ("0" + dat.getHours()).slice(-2)
+ ("0" + dat.getMinutes()).slice(-2);
name = item.newBasename.match(/(.*_)(.*_)(.*_)(\d{10})(_.*)/);
dat = new Date(1000 * parseInt(name[4]));
return name[2]
+ dat.getFullYear()
+ "-" + ("0" + dat.getMonth()).slice(-2)
+ "-" + ("0" + dat.getDate()).slice(-2)
+ "_" + ("0" + dat.getHours()).slice(-2)
+ "-" + ("0" + dat.getMinutes()).slice(-2)
+ "-" + ("0" + dat.getSeconds()).slice(-2)
+ name[5];
#2 : 07/05-25 03:38
Delta Foxtrot
Posts: 475
Reply to #1:

Hi Ted,

Welcome back, and, by the way, congratulations on that whole Boston tunnel thing. Good work! :)

The simplest way, I think, is simply to use the adjustment parameter in the <UnixTimestamp Modified> tag. I can't swear to it, but 30 seconds of testing leads me to believe if you change the line:

epoch = app.parseTags("<UnixTimestamp Modified>");

to:

epoch = app.parseTags("<UnixTimestamp Modified:+5h>");

that may fix your hour problem (and save you a lot of sweat that Kim has already put in taking into account changing days and years in the adjustment).

This page: https://www.advancedrenamer.com/user_guide/v4/ta gs_datetimemodified at the bottom says all these date/time tags in the latest version of ARen are adjustable to take into account this kind of thing.

This page: https://www.advancedrenamer.com/user_guide/v4/ta gs_datetime#adjusting-output-value describes the adjustments that can be made.

Good luck!

Best,
DF

edited: 07/05-25 03:39
#3 : 07/05-25 03:43
Delta Foxtrot
Posts: 475
Reply to #2:

Oh, if for some reason that doesn't give you the correct time you can probably do something like:

epoch = app.parseTags("<UnixTimestamp Modified>");
dat = ( new Date(1000 * epoch) + ( 5 * 3600) ) ;

I suspect (but can't guarantee) that will work.

Cheers!

EDIT: Tried it; didn't work... anyway, the first method seems to work.

BTW, did you mix two scripts together in your example? There are two returns with no qualifying "if" statement. I don't really understand, and it's been a while since I've had to deal with anything like that.

edited: 07/05-25 04:07
#4 : 07/05-25 04:14
Delta Foxtrot
Posts: 475
Reply to #3:

Couldn't you also just use a NEW NAME method with:

<Date Modified:yyyymmdd_hhnnss:+5h>

?