Chart times are broker times.
How can MetaQuotes know all brokers' (they come and go daily) Time zone and Daylight savings time (if they use it and including historical changes for back testing)? Do you have that information for just you and your broker? Only then, with code can you convert session times to broker's time to UTC to local time. You can use offset inputs but then you must maintain them correctly, through all three DST changes when they occur.
When is the time zone problem going to be fixed? - General - MQL5 programming forum (2020.05.07)
You asked for “any date.” Not possible unless you know your exact broker's TZ.
To convert current broker to local or back, see Time[5] in Local Time? - MQL4 programming forum #1 (2020.12.16) Substitute TimeGMT for local.
Thank you for you response. I don't want change the broker MT4 timezone.
I need convert a date from a timezone to UTC.
Thank you.
Helo again,
you are not understanding what i need. I don't want to change the time of the broker
I want to convert a date, on a datetime variable, in a specific time zone, to another time zone
Something like this:
var m = moment.tz("2013-11-18 11:55", "America/Toronto"); m.tz("Europe/Berlin").format(); // 2013-11-18T06:00:00+01:00
is it clear now?
Thank you
Helo again,
you are not understanding what i need. I don't want to change the time of the broker
I want to convert a date, on a datetime variable, in a specific time zone, to another time zone
Something like this:
is it clear now?
Thank you
then is just a matter of summing the difference in seconds for the hour/minutes shift you need because the datetime type is just an
integer number representing the seconds elapsed since 1970-01-01 00:00.
Maybe you'll find your answers here:
https://www.mql5.com/en/articles/9926
https://www.mql5.com/en/articles/9929
There's no function to retrieve the broker's timezone, so your indicator/EA will have to have a parameter to adjust this for each broker,
then is just a matter of summing the difference in seconds for the hour/minutes shift you need because the datetime type is just an
integer number representing the seconds elapsed since 1970-01-01 00:00.
Maybe you'll find your answers here:
https://www.mql5.com/en/articles/9926
https://www.mql5.com/en/articles/9929

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
Is it possible to convert any date on a specific zone to UTC?
For example if I have 10/10/2021 in the 'Europe/London' zone, how could change it to UTC (taking into account the daylight saving)?
In javascript there is momentjs library, but I don't know how to do it in MQL5
Thanks