Time[5] in Local Time?

 

Hello,

is there an easy way to convert any timestamp from MT4 time to local time?

Something like TimeLocal(Time[5])?

I tried it with TimeGMTOffset(), TimeDaylightSavings() and some other things but it doesn't really work..

Any help is very appreciated.

 
Marbo: is there an easy way to convert any timestamp from MT4 time to local time?
  1. There is no such thing as “MT4 time”. Chart are broker's time.

  2. Round the offset of server to local time to the nearest half hour:

    double      MathNearest(  double aV, double aM){ return aM * MathRound(aV/aM); }
    double      MathRoundDown(double aV, double aM){ return aM * MathFloor(aV/aM); }
    double      MathRoundUp(  double aV, double aM){ return aM * MathCeil( aV/aM); }
    
    int gLocalToServer = (int)MathNearest(TimeCurrent() - TimeLocal(), 1800);
    
    datetime serverTime  = TimeLocal() + gLocalToServer;
    datetime localTime   = TimeCurrent() - gLocalToServer;
    
              how can i detect that 10 seconds to bar close? MT4/EA - MQL5 programming forum 2020.04.24
              Indicators: Zero Lag Timer - Indices - Articles, Library comments - MQL5 programming forum

  3. That will not work across DST changes.

 
William Roeder:
  1. There is no such thing as “MT4 time”. Chart are broker's time.

  2. Round the offset of server to local time to the nearest half hour:

              how can i detect that 10 seconds to bar close? MT4/EA - MQL5 programming forum 2020.04.24
              Indicators: Zero Lag Timer - Indices - Articles, Library comments - MQL5 programming forum

  3. That will not work across DST changes.

Thank you!

Reason: