# how does date and time exactly work?

6190

hello everybody,

I want to programm an EA, that opens at a certain time (which the user can define) pending orders and I have problems with this date and time functions like TimeCurrent().

Until now I have this:

extern datetime time = D'2014.08.15 11:10:00';

and now I want to compare this time with the TimeCurrent() to open a pending order. The Question is: what argument should I put in the bracket? I don't really understand the definition in the documentary

https://docs.mql4.com/dateandtime/timecurrent

The next question I have is: Is there the possibility to 'do math' with this datetime. For example if I have again the time defined like above, how can I define NewTime=time +3minutes ??

It would be very helpfull if somebody can answer. Thanks a lot

Moderator
18003

cornesti:

hello everybody,

I want to programm an EA, that opens at a certain time (which the user can define) pending orders and I have problems with this date and time functions like TimeCurrent().

You need to understand what a datetime  (<---- link, please click me  ) type variable is . . .  ". . .   as the number of seconds elapsed since January 01, 1970"

If you want the datetime 3 minutes from now . . . TimeCurrent() + 3 * PERIOD_M1 * 60

14779

 cornesti: The Question is: what argument should I put in the bracket?  The next question I have is: Is there the possibility to 'do math' with this datetime. What bracket?Like this ```#define HR2400 (PERIOD_D1 * 60)  // 86400 = 24 * 3600 int      TimeOfDay(datetime when=0){ if(when == 0) when = TimeCurrent();    return( when % HR2400 ); } datetime DateOfDay(datetime when=0){ if(when == 0) when = TimeCurrent();    return( when - TimeOfDay(when) ); } //datetime Tomorrow( datetime when=0){ if(when == 0) when = TimeCurrent(); //   return(DateOfDay(when) + HR2400); } //datetime Yesterday(datetime when=0){ if(when == 0) when = TimeCurrent(); //   int iD1 = iBarShift(NULL, PERIOD_D1, DateOfDay(when) - 1); //   return( iTime(NULL, PERIOD_D1, iD1) ); }```
6190

thanks a lot guys, now I know how to do it. With the bracket I meant the one after TimeCurrent(). But it's the same think as in Symbol(), doesn't need any input arguments.

whish you a nice weekend

14779

cornesti: With the bracket I meant the one after TimeCurrent().
CharacterUS EnglishUK EnglishIndia
()ParenthesesBraces, round brackets, curved brackets, oval brackets
[]BracketsSquare Brackets
{}BracesCurly bracketsflower bracket
<>Angle brackets (or chevrons)
Moderator
18003

WHRoeder:
cornesti: With the bracket I meant the one after TimeCurrent().