Download MetaTrader 5
To add comments, please log in or register
How to earn at MQL5.community? Come and find out!
Winsor Hoang
4743
Winsor Hoang 2014.12.15 05:19 

Hi,

 Please help me with a script that will convert the following MT4 date to regular date i.e. day/month/year

 

start_date=1388534400
end_date=1415059200


many thanks
honest_knave
969
honest_knave 2014.12.15 06:16  

If you're happy to accept their format, take a look at TimeToString().

Otherwise, take a look at the MqlDateTime structure and TimeToStruct() which will give more flexibility on the output format.

Depends really on what you plan to do with the data, and the context of your question.

whroeder1
13630
whroeder1 2014.12.15 14:17  
waterhorse: MT4 date to regular date i.e. day/month/year
  1. honest_knave: TimeToString().
  2. variations like
    string DDMMYYYY(datetime d){ // 01/01/2015
       return Stringformat("%02i/%02i/%i" TimeDay(d), TimeMonth(d), TimeYear(d) );
    }
    string DMYY(datetime d){   // 1/1/15
       return Stringformat("%i/%i/%02i" TimeDay(d), TimeMonth(d), TimeYear(d) % 100 );
    }
    :
    string c = StringFormat("From %s to %s", DDMMYYYY(start_date), DDMMYYYY(end_date));

Winsor Hoang
4743
Winsor Hoang 2014.12.15 14:28  

Thanks got it!

/
To add comments, please log in or register