Date format function

 

Hi Folks!

When I was debugging my EA orders I wanted to print when they was created. But the OrderOpenTime() function returns timestamp number so it is hard to read the date from it without any tool or conversion. So I made a nice function that convert eg. 12313132 into a string like 2006.03.12 12:33 so it can be read very easy.

Here it is:

string dateFormat(int timestamp)

{

string m,d,h,mi;

int month = TimeMonth(timestamp);

int day = TimeDay(timestamp);

int hour = TimeHour(timestamp);

int minute = TimeMinute(timestamp);

if(month<10)

m = "0"+month;

else

m = month;

if(day<10)

d = "0"+day;

else

d = day;

if(hour<10)

h = "0"+hour;

else

h = hour;

if(minute<10)

mi = "0"+minute;

else

mi = minute;

return(StringConcatenate(TimeYear(timestamp),".",m,".",d," ",h,":",mi));

}

U can use it as u want hope it will be helpfull for someone.

Cheers

Kalenzo

 

but .. what about TimeToStr() function?

 
phoenix:
but .. what about TimeToStr() function?

U right, sometimes I'm missing something which goes without saying...

 

date and time switch on off

hi,

can you give me sample script or EA to start EA on monday set time and close friday set time.

TQ