Changing time and date format in mql4

 
Hi Can we change the time format in mql4 from 2013.09.09 13:15 to 30130909 1315 Any help is appreciated and thnx in advance
 
abdI: Can we change the time format i
NO
 
abdI:
Hi Can we change the time format in mql4 from 2013.09.09 13:15 to 30130909 1315 Any help is appreciated and thnx in advance
It all depends on what you are talking about, what do you do exactly ?
 
hi thanks for u  WHRoeder , angevoyageur ,  i want to show the time on the screen of my mt4 terminal as 30130909 1315 (yyyymmdd hhmm) for example  using  

ObjectCreate(".....", OBJ_LABEL, 0, 0, 0);
ObjectSetText("....",DoubleToStr((..);


and after getting the time format as the above then i can  do any mathematical operations on it by considering it to be a (number)  not (date)  

 i know that we can get time format as 30130909 1315 by creating and saving the price data as  .prn, file but 

am looking for a way to get it directly on the screen of my mt4 terminal " if i could ".

 
abdI:
hi thanks for u  WHRoeder , angevoyageur ,  i want to show the time on the screen of my mt4 terminal as 30130909 1315 (yyyymmdd hhmm) for example  using  



and after getting the time format as the above then i can  do any mathematical operations on it by considering it to be a (number)  not (date)  

 i know that we can get time format as 30130909 1315 by creating and saving the price data as  .prn, file but 

am looking for a way to get it directly on the screen of my mt4 terminal " if i could ".

datetime  timeformat   =  TimeCurrent();

Print("  Time  " ,timeformat);

 

What output do you have this way ??? 

 
deVries:

 

What output do you have this way ??? 


hi and thanks for you deVries

am not good in mql4 programming, but as i know the print function will send the output to the log file ..(am not sure as am beginner )

 can we show the output on the screen of mq4 terminal ? using object creat?

 

 and here what i found in the log file

 

 

15:29:32 #time EURUSD,Daily:   Time  1366385328
15:29:32 #time EURUSD,Daily:   Time  1366385328
 

oh ....what a big mistake ..................about the needed time format.......it should be.20130909 1315  not...30130909 1315.

....... 

in all of my previous posts i made the same mistake.....sorry   .hope any Moderator to correct it 

 
abdI:

oh ....what a big mistake ..................about the needed time format.......it should be.20130909 1315  not...30130909 1315.

....... 

in all of my previous posts i made the same mistake.....sorry   .hope any Moderator to correct it 

You can construct the string using  StringConcatenate(int, int, int, int, )  with  TimeYear(TimeCurrent() )  TimeMonth(TimeCurrent)  TimeDay(TimeCurrent)   etc.
 
RaptorUK:
You can construct the string using  StringConcatenate(int, int, int, int, )  with  TimeYear(TimeCurrent() )  TimeMonth(TimeCurrent)  TimeDay(TimeCurrent)   etc.


hi

i will tray this function  ....

thanks for u RaptorUK . 

 
  1. abdI: it should be.20130909 1315  not...30130909 1315. (yyyymmdd hhmm)
    From TimeToStr - MQL4 Documentation TimeToStr returns "yyyy.mm.dd hh:mi". So strip out the separators.
    Not compiled, not tested.
    string TimeToStringNS(datetime when){
      string withSep = TimeToStr(when),              // "yyyy.mm.dd hh:mi"
             withOut = StringSubstr(withSep,  0, 4)  // yyyy
                     + StringSubstr(withSep,  5, 2)  // mm
                     + StringSubstr(withSep,  8, 5)  // dd hh
                     + StringSubstr(withSep, 14, 3); // mi
      return(withOut);                               // "yyyymmdd hhmi"
    }
    Not compiled, not tested.

  2. RaptorUK: You can construct the string using  StringConcatenate(int, int, int, int, )  with  TimeYear(TimeCurrent() )  TimeMonth(TimeCurrent)  TimeDay(TimeCurrent)  etc.
    Using TimeMonth(x), etc., will not result is 2 digit values but instead yyyymd hm in general.