This was just tested and do seem to work as expected:
datetime var1; string date1; var1=StrToTime("2011.7.17 22:30");//given date & time var1 = var1 + (5 * 3600);//given offset of +5 hours date1 = TimeToStr(var1,TIME_DATE|TIME_MINUTES); Comment(var1 + " " + date1);//corrected date & timeHave I overlooked something here ?
DayTrader:
This was just tested and do seem to work as expected:
Have I overlooked something here ?Looks OK to me . . .
"Date & Time functions
A group of functions providing the working with data of the datetime type (integer representing the amount of seconds elapsed from midnight, 1 January, 1970). "
DayTrader:
Have I overlooked something here ?
Have I overlooked something here ?
var1=StrToTime("2011.7.17 22:30")or
var1=D'2011.7.17 22:30';
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
Hi, I need to add or subtract a given amount of time to a given time and date.
Lets say we have the given time of Jul 17 2011 22:30
and I want to add 05:00 (5 hrs) to that datetime, giving Jul 18 2011 03:30
How to do this in a simple way? Dealing with hours alone is simple, just add and take care of the day rollower.
Can it be done by simply converting the given date and time to seconds since 1970, add (5x3600), and
convert back to datetime ??