Avatar of ReneGe
ReneGe
Flag for Canada asked on

Batch File: Fix date and time with Time Zone

Hi there,

I have a date, and a time at 0GMT.

To need a batch file to change them according to -5GMT

For example:
2014-01-10 00:44:34  -> 2014-01-09 19:44:34
2014-02-01 00:44:34 -> 2014-01-31 19:44:34
2014-02-01 20:44:34 -> 2014-02-01 15:44:34

Thanks for your help,
Rene
Microsoft DOSWindows BatchProgramming

Avatar of undefined
Last Comment
Bill Prew

8/22/2022 - Mon
Jon Covalt

Add the following to a batch file:

TZUTIL /s "Eastern Standard Time"
ReneGe

ASKER
hey CorinTack, thank for your prompt reply.

I don't need to change the time zone of my PC.

For example:

@ECHO OFF
CALL :TimeZone "2014-01-10 00:44:34"
ECHO %NewDate% %NewTime%
PAUSE
EXIT

:TimeZone
REM Code nere
EXIT /b
ASKER CERTIFIED SOLUTION
Bill Prew

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ReneGe

ASKER
Hey buddy, its been a while :)

here is my output:
Expected: 2014-01-09 19:44:34
tzAdjust: 2014-01-09 19:44:34

Expected: 2014-01-31 19:44:34
tzAdjust: 2014-01-31 19:44:34

Expected: 2014-02-01 15:44:34
tzAdjust: 2014-02-01 15:44:34

Cheers
Your help has saved me hundreds of hours of internet surfing.
fblack61
Bill Prew

Correct, that's the proper output, as you requested.

~bp
ReneGe

ASKER
Whats wrong with me???

Thanks Bill :)
Bill Prew

Welcome Rene.

~bp
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.