//+------------------------------------------------------------------+ //--- Time Functions ------------------------------------------------+ //+------------------------------------------------------------------+ int TimeYear (datetime date){MqlDateTime time;TimeToStruct(date,time);return(time.year);} int TimeMonth (datetime date){MqlDateTime time;TimeToStruct(date,time);return(time.mon);} int TimeDayOfYear(datetime date){MqlDateTime time;TimeToStruct(date,time);return(time.day_of_year);} int TimeDayOfWeek(datetime date){MqlDateTime time;TimeToStruct(date,time);return(time.day_of_week);} int TimeDay (datetime date){MqlDateTime time;TimeToStruct(date,time);return(time.day);} int TimeHour (datetime date){MqlDateTime time;TimeToStruct(date,time);return(time.hour);} int TimeMinute (datetime date){MqlDateTime time;TimeToStruct(date,time);return(time.min);} int TimeSecond (datetime date){MqlDateTime time;TimeToStruct(date,time);return(time.sec);} //+------------------------------------------------------------------+ // example code //--- Print("The Year is: ",TimeYear(TimeCurrent())); Print("The Month is: ",TimeMonth(TimeCurrent())); Print("The Day of Year is: ",TimeDayOfYear(TimeCurrent())); Print("The Day of Week is: ",TimeDayOfWeek(TimeCurrent())); Print("The Day is: ",TimeDay(TimeCurrent())); Print("The Hour is: ",TimeHour(TimeCurrent())); Print("The Minute is: ",TimeMinute(TimeCurrent())); Print("The Second is: ",TimeSecond(TimeCurrent())); //--- // //+------------------------------------------------------------------+
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I would like to ask you some tips for a MQL5 variable (for EA), which must return the amount of seconds elapsed from the beginning of the minute of the specified time.
It is essentially what TimeSeconds() is in mql4... could you please help me to define somethign equivalent in MQL5?
Thank you very much!