An indi, EA or script in mt4 you can get today's date by Time[0] - which is the time-stamp of the most recent bar. During a weekend it is the timestamp of the last bar from Friday!
In the tester Time[0] is the actual time-stamp of the last bar of the pointer of the tester.
Or do you want to know how to compose the date formate a string: 1-Jan-2017?
Use TimeDay(), TimeMonth() (you have to convert:1="Jan",2=..) , TimeYear().
An indi, EA or script in mt4 you can get today's date by Time[0] - which is the time-stamp of the most recent bar. During a weekend it is the timestamp of the last bar from Friday!
In the tester Time[0] is the actual time-stamp of the last bar of the pointer of the tester.
Or do you want to know how to compose the date formate a string: 1-Jan-2017?
Use TimeDay(), TimeMonth() (you have to convert:1="Jan",2=..) , TimeYear().
That method got time from last candle on backtest , not get today date.
but thanks , l want to get real today date ,like check from broker.
Regards
Your questions is confusing and unclear!
- You either want today's date/time irrespective of Broker time, using TimeLocal() or TimeGMT(),
- or you want the brokers current time, using TimeCurrent() (or Time[0] and equivalents).
During testing in the Strategy Tester, TimeLocal() is always equal to TimeCurrent() simulated server time.

- docs.mql4.com
Can't be done, except using DLL/Windows call.
TimeGMT - Date and Time - MQL4 Reference
TimeLocal - Date and Time - MQL4 Reference
Can't be done.
it can be done)
it can be done)
Excuse me how to do that?
Thank you.
Siwakon Poonsawat:
- Not work. Tested TimeCurrent() and Time[0] no way to get real today date.
- Excuse me how to do that?
- As already stated TimeCurrent() and Time[0] returns Broker Time, not Local time and also during testing in the Strategy Tester, TimeLocal() is always equal to TimeCurrent() simulated server time.
- However, you can use Win32 API functions ( eg. GetSystemTime() ) to get the real current local time, circumventing the limitations of the Strategy Tester.
EDIT: See the following related posts:

- docs.mql4.com
OP wants to get local time while using the Strategy Tester, hence why the Win32 API suggestion.
Obviously, when not using the Strategy Tester, but on a Live chart, you don't need to use the Win32 API.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
l have tried many code , but still can't find way to get today date.
Example Today = 10-Sep-2017
When l doing backtest on = 1-Jan-2015
How to get today date?
Thank you.
Best regards.