Download MetaTrader 5
To add comments, please log in or register
Do you need OpenCL? MQL5 can provide it!
beh12zad
29
beh12zad 2016.10.01 09:00 

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?


Ovo Cz
2951
Ovo Cz 2016.10.01 09:13  
string  TimeToStr( 
   datetime  value,                           // value 
   int       mode=TIME_DATE|TIME_MINUTES      // format 
   );
Fernando Carreiro
1513
Fernando Carreiro 2016.10.01 11:52  

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
13640
whroeder1 2016.10.01 12:14  
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
1513
Fernando Carreiro 2016.10.01 12:43  
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
13640
whroeder1 2016.10.01 18:23  
OP
/
To add comments, please log in or register