From in EA, get time, or GMT offset, in any timezone, independent of server location or running EA location

 

Details a bit vague here, to try to keep it brief. Happy to elaborate if needed.

The MQL5 date and time functions include functions for getting time information in the time zone the EA is running in, or the broker's server's time zone, or the GMT time zone.  The functions either factor in daylight saving, or give me the ability to do so (TimeDaylightSaving() function), but again still only in the timezones of the EA, the broker, or GMT. At least that's what I'm seeing so far.

Is there any way to determine time information (current time, if nothing else) in some other time zone (regardless of the location or time settings of the computer my EA is running on, or my broker's server), including factoring in daylight saving, (without having to know or explicitly code in the dates for when daylight saving changes in or out in that time zone)?

Thanks!

Documentation on MQL5: Date and Time / TimeCurrent
Documentation on MQL5: Date and Time / TimeCurrent
  • www.mql5.com
TimeCurrent - Date and Time - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
David _Detnator_: The MQL5 date and time functions include functions for getting time information in the time zone the EA is running in, or the broker's server's time zone, or the GMT time zone.  The functions either factor in daylight saving, or give me the ability to do so (TimeDaylightSaving() function), but again still only in the timezones of the EA, the broker, or GMT. At least that's what I'm seeing so far.

Is there any way to determine time information (current time, if nothing else) in some other time zone (regardless of the location or time settings of the computer my EA is running on, or my broker's server), including factoring in daylight saving, (without having to know or hardcode in the dates for when daylight saving changes in or out in that time zone)?

Just take some time to analyse your question logically:

In order to know the time of any other place in the world, including their respective DST's, you would need to keek track of a database of the world, or in the very least a database of every time-zone by name such as EET or WET or PST, etc.

Now, not even Windows does that fully, only partially. It does have a time-zone database but can only keep track of up a maximum of two extra clocks besides the main one, and it polls time servers in order to keep them synchronised.


So in answering your question "Is there any way to determine time information in some other time zone", the answer is as follows:

Only if you do it yourself,
  • by keeping track of your own database, or
  • by using Windows API to access its time-zone database (or extra clocks).
 
Fernando Carreiro #:

Just take some time to analyse your question logically:

In order to know the time of any other place in the world, including their respective DST's, you would need to keek track of a database of the world, or in the very least a database of every time-zone by name such as EET or WET or PST, etc.

Now, not even Windows does that fully, only partially. It does have a time-zone database but can only keep track of up a maximum of two extra clocks besides the main one, and it polls time servers in order to keep them synchronised.


So in answering your question "Is there any way to determine time information in some other time zone", the answer is as follows:

Only if you do it yourself,
  • by keeping track of your own database, or
  • by using Windows API to access its time-zone database (or extra clocks).

Fernando... sometimes you're really awesome, and I'm very grateful for all the help you've been to me so far.  But could I possibly offer you an opportunity at some personal growth?  Sometimes you can be unnecessarily ... what's the word ... condescending. Is that really needed?  I don't mean to offend you, at all, and no hard feelings or anything, but would it be out of line for me to ask you to consider that?

Not sure why you'd think I didn't take some time to analyze this question before posting it... 

I have apps on my Mac that can tell me the time anywhere in the world, right now, or at pretty much any time at least a few hundred years either side of now. And of course there are countless websites and rest APIs that can tell me in a heartbeat. In Javascript I can write an app in a few lines of code that can ping any one of those APIs or servers like whatever Windows polls to tell me any of that information (although I think Javascript can tell me without me having to specifically write that -- certainly some languages I've worked with can... whether they ping a server or API to fulfill the language command, or track their own database, I don't know... nor care). And it's not like MT5 can't access the internet. Why would it be so unreasonable for me to believe (and therefore ask if) MT5 might, or should, be able to tell me, but I just haven't been able to find or figure out how?

I can understand "not even Windows does that fully."  I'm not going to hide the fact that in my opinion Windows sucks compared to macOS, and this would be one of the reasons.

But actually (and I write the following in case it helps anyone else sometime) after posting this question, I thought a little more about that REST point. If MQL5 can 't do this with any native functions, but REST is how at least some other languages do it (either built in, or the ability to write a REST call to do it), then perhaps MQL5 can too? And if so that opens up a world of other information I can get, and even post, also.

I couldn't find anything in the documentation or help mentioning REST, but searching the forum someone mentions calling REST APIs with MQL5's WebRequest() function. I wasn't aware of that function before reading that. I'm still looking into it, but it looks like the right parameters in that function could solve this in one function call. Agreed, I'm sure the Windows API is another approach (and certainly a good answer if I was more comfortable with that than I am with REST calls) but I think that might be a bit beyond me anytime soon.

I left the question here because I still hoped there would be something more native. You've confirmed that at least your (obviously pretty extensive) knowledge is not aware of any native option for this. So that suggests my time spent researching WebRequest() will likely be worthwhile even for the immediate need (aside from future benefits).

So as with all the help you've given me so far, thank you also for this! 😊