How do I add/subtract from time?

 
I would like to be able to subtract 2-3 hours from the current time. What's the formula to do this?
 
TimeCurrent( )
is counted in seconds. So your time:
datetime yourtime=TimeCurrent()-2*3600;//or 3*3600
 

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


with Thanks and regards.

 

The key concept is "is counted in seconds".

Then do basic math.

 

@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

 
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?
 

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

 
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.
 
Alexander #:
TimeCurrent( )
is counted in seconds. So your time:
Hi dear friend
I do not know you
But I hope God gives you everything you want in your life
And always be healthy
I've been looking for a code for a month that can plus openpositiontime with30min
I wrote a program that was very complicated, but it didn't work out
I saw something of your code today
And the answer was only 2 words (+1800)
The code that did not answer in twenty lines, you wrote in two words
Thank you for being
 
Alexander #:
TimeCurrent( )
is counted in seconds. So your time:

WHAT about add 20 SECONDS

datetime yourtime=TimeCurrent()+20;
if (yourtime)
{
if(ObjectName(cnt)>=0)
{
ObjectsDeleteAll();
WindowRedraw();
 
  1. DERIKO02 #: WHAT about add 20 SECONDS

    What about it? What part of

    peter.MT4Web #:The key concept is "is counted in seconds". Then do basic math.

    was unclear to you?


  2. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum (2019)
              Messages Editor

  3. if (yourtime)
    Zero is false and non-zero true. So yourtime will always be non-zero and thus always true.
Reason: