You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Most likely the guy was looking for something like this…
string ConvertSecondsToHHMMSS(uint TimeSpenInSec)
{
double NumHours = 0; // There are 60 minutes per 1 Hour or 60 * 60 = 3600 seconds per 1 Hour
double NumMinutes = 0; // There are 60 sec per 1 Min
double NumSeconds = 0;
NumHours = MathFloor(TimeSpenInSec / 3600);
NumMinutes = MathFloor(MathMod(TimeSpenInSec / 60, 60));
NumSeconds = MathMod(TimeSpenInSec, 60);
return(StringFormat("%02d:%02d:%02d", (int)NumHours,
(int)NumMinutes,
(int)NumSeconds));
}
This is a very different question, can't you keep both servers synced with some world atomic clock?
This is very easy and you can sync both servers every minute.
Servers clock skills can prevent SSL, HTTPS and cryptographic system communications and functions to correctly work.
Think about it.
perhaps it is too late but I was looking for a ready solution to calculate the difference between two times even if the times are in two following years, so I faced this topic.
than I write as follow, which works correctly for my application:
as a same way with related changes it could be use to calculate in minutes or seconds as well.
Simplify, the difference between to datetimes is in seconds.
Simplify, the difference between to datetimes is in seconds.
I tested your approch the result is not true in any kind of time unit. In my case I wanted to calculate the hour differencies between last close time to current time.
Without convertion same as your approch, you will have false result.
eg. t1=2022.07.19 12:00 and t2=2022.07.20 12:00 the result without convertion and caring the different day will be 0 but not 24!
this will be even worse if t1=2021.12.30 12:00 and t2=2022.01.01 12:00
thanks your comment anyway.
I tested your approch the result is not true in any kind of time unit. In my case I wanted to calculate the hour differencies between last close time to current time.
Without convertion same as your approch, you will have false result.
eg. t1=2022.07.19 12:00 and t2=2022.07.20 12:00 the result without convertion and caring the different day will be 0 but not 24!
this will be even worse if t1=2021.12.30 12:00 and t2=2022.01.01 12:00
thanks your comment anyway.
Please show your code that gives incorrect results.
William's function is simple and it works correctly.
If you are getting incorrect results it must be due to your mistake.
Prove it. You are making assumptions.
Prove it. You are making assumptions.
sorry you are right. that was my mistake also due to false probe times and wrong interpretation of my similar approch.
my first approch was similar to yours but without division; instead i used function TimeHour() as follow:
that was for this purpose realy disaster.
furthermore during complition of your code i got an warning, which mentioned the compiler needs an appropriate interpretator namely (int). So I asume my wrong assumtion based on my wrong test is true.
I using it yet as follow
sorry and thanks for the tip.
Prove it. You are making assumptions.
Actually, I didn't pay attention to " the difference between to datetimes is in seconds"!
thanks again