Download MetaTrader 5

Detect Timzone

To add comments, please log in or register
strontiumDog
286
strontiumDog  
Hello
Every tick, I want to update a variable with the current server time zone. 

I can't find how this is done within mql4.
I'd rather avoid having to scrape this off the web. 

Can anyone tell me how to do this?

Thanks
Keith Watford
Moderator
9641
Keith Watford  
strontiumDog:
Hello
Every tick, I want to update a variable with the current server time zone. 

I can't find how this is done within mql4.
I'd rather avoid having to scrape this off the web. 

Can anyone tell me how to do this?

Thanks
Why? the server's time zone won't change.
whroeder1
14774
whroeder1  
strontiumDog: , I want to update a variable with the current server time zone.
datetime server = TimeCurrent(), gmt = TimeGMT();
int TZ = (int) MathRound( (gmt - server) / 3600.0 );
This will not work in the tester, however. This may change on DST.
strontiumDog
286
strontiumDog  
GumRai:
Why? the server's time zone won't change.
Replying with that is clearly unhelpful.
strontiumDog
286
strontiumDog  
WHRoeder:
strontiumDog: , I want to update a variable with the current server time zone.
This will not work in the tester, however. This may change on DST.

Thanks for the suggestion WHRoeder.

The code returns the difference between GMT and the current, which is fine, and I can extrapolate from there, but I'm on GMT and BST, depending on the date.  You're right, it may change on DST, but in my case it won't as the terminal is on the same time zone as the server.  What I was really looking for was a string that instantiates to 'BST' or 'GMT' etc. or a value which is different today (Sep 9 uk, BST) to this time in 2 months (Nov 9, uk, GMT).  Actually, I guess I could use UTC.

Zirkon
122
Zirkon  
strontiumDog:
Replying with that is clearly unhelpful.

If you want an helpful answer, maybe you should think why people are helping others on a forum ?

Personally I am interested by Gumrai's question and your reaction doesn't encourage me to help you.

To add comments, please log in or register