Convert to Date and Time

 

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
 

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.

 
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));

 

Thanks got it!

Reason: