Seconds left = specific time - current time. Convert your string to time. If the converted time is in the past, add 24 hours.
Seconds left = specific time - current time. Convert your string to time. If the converted time is in the past, add 24 hours.
string Time1 = "09:00:00"; string Time2 = TimeToStr(TimeLocal(), TIME_SECONDS); WriteText (del + "SydnayOpens", Time1 - Time2, "Arial", White, 205, 125, "\n", 9, 2, ANCHOR_LEFT_LOWER, FALSE);
'-' - illegal operation use
Convert your strings to time.
You can not subtract string values.
https://www.mql5.com/en/articles/599- www.mql5.com
Convert your strings to time.
You can not subtract string values.
https://www.mql5.com/en/articles/599When I'm converting string to time and subtracting I'm getting some numbers like (-52447) and when I'm converting this numbers back to string with TimeToString() it's not giving me anything
What part of "If the converted time is in the past, add 24 hours," is unclear to you.
What part of “Seconds left =” is unclear to you. You can't convert seconds left to a datetime and then to a string.
datetime SYsT = StrToTime("09:00:00") - (TimeLocal() + (( 11 - Timezone) * 3600)); TimeToStr(SYsT, TIME_SECONDS)
I finally did it ...
Thanks all
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Is there a way to calculate how much time is left from current time to a specific time? Like if I have time string "09:00" and current time is 20:40, how to calculate difference between those times?
That's my code for New York time:
There is 11:43 now and if I have specific time like 09:00 how to calculate how much time left till 09:00?