Download MetaTrader 5

Converts value containing time in seconds that has passed since January 1 in , 1970 , into a string of "yyyy.mm.dd hh:mi:ss" format.

To add comments, please log in or register
beh12zad
30
beh12zad  

I am writing an Indicator by Trade Function OrderOpenTime() I get the Time in Seconds,

I want to convert the output  into a string of "yyyy.mm.dd hh:m:ss" format.

how can I do it?


Ex Ovo Omnia
3293
Ex Ovo Omnia  
string  TimeToStr( 
   datetime  value,                           // value 
   int       mode=TIME_DATE|TIME_MINUTES      // format 
   );
Fernando Carreiro
2203
Fernando Carreiro  

When in doubt, consult the documentation. You used the word "convert", therefore in the documentation, read-up on "Conversion Functions".

There you will find "TimeToString()" which is the more modern version, compatible with MQL5, which is equivalent to the older name of "TimeToStr()".

string  TimeToString(
   datetime  value,                           // number
   int       mode=TIME_DATE|TIME_MINUTES      // output format
   );

string  TimeToStr(
   datetime  value,                           // value
   int       mode=TIME_DATE|TIME_MINUTES      // format
   );

Parameters

value

[in]  Time in seconds from 00:00 1970/01/01.

mode=TIME_DATE|TIME_MINUTES

[in] Additional data input mode. Can be one or combined flag:
TIME_DATE gets result as "yyyy.mm.dd",
TIME_MINUTES gets result as "hh:mi",
TIME_SECONDS gets results as "hh:mi:ss".

Return Value

String.

whroeder1
15554
whroeder1  
FMIC: When in doubt, consult the documentation.
Bookmark the following
  1. List of MQL4 Functions - MQL4 Reference
  2. List of MQL4 Constants - MQL4 Reference
Fernando Carreiro
2203
Fernando Carreiro  
WHRoeder:
FMIC: When in doubt, consult the documentation.
Bookmark the following
  1. List of MQL4 Functions - MQL4 Reference
  2. List of MQL4 Constants - MQL4 Reference
Is that a message for me or for the OP?
whroeder1
15554
whroeder1  
OP
To add comments, please log in or register