Download MetaTrader 5

How do I add/subtract from time?

To add comments, please log in or register
Tyler Moore
19
Tyler Moore  
I would like to be able to subtract 2-3 hours from the current time. What's the formula to do this?
Alexander
2441
Alexander  
TimeCurrent( )
is counted in seconds. So your time:
datetime yourtime=TimeCurrent()-2*3600;//or 3*3600
Saravanakumar D
360
Saravanakumar D  

Nice work bro.. How to add 2 and half or 3 and half.


with Thanks and regards.

peter.MT4Web
157
peter.MT4Web  

The key concept is "is counted in seconds".

Then do basic math.

Saravanakumar D
360
Saravanakumar D  

@eddie... i can also do the same message to all the topic bro.. if i know the code why do i ask here?..

Kindly put code as @Roger say's.


Thanks

Keith Watford
Moderator
10614
Keith Watford  
d.saravana21:

@eddie... i can also do the same message to all the topic bro.. if i know the code why do i ask here?..

Kindly put code as @Roger say's.


Thanks

You have been shown how to subtract 2 or 3 hours. Isn't adding so many hours obvious?
Saravanakumar D
360
Saravanakumar D  

Oops... I found my self.. Now a day's it's hard to have help from this forum peoples.. it was nice and cool before 2010..any way have happy and healthy life brother...

it's like  mytime+2.5*3600; //3.5*3600 for 3 and half hours

with Thanks and Regards

Keith Watford
Moderator
10614
Keith Watford  
d.saravana21:

Oops... I found my self.. Now a day's it's hard to have help from this forum peoples.. it was nice and cool before 2010..any way have happy and healthy life brother...

it's like  mytime+2.5*3600; //3.5*3600 for 3 and half hours

with Thanks and Regards

If you get spoon-fed the total answer, you learn nothing. If you are given an answer that forces you to use your own brain a little, you learn.
To add comments, please log in or register