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.

 

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?


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

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.

 
FMIC: When in doubt, consult the documentation.
Bookmark the following
  1. List of MQL4 Functions - MQL4 Reference
  2. List of MQL4 Constants - MQL4 Reference
 
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?
 
OP
Reason: