Hello I have a .csv with times as strings in the format:
"2018-04-10 15:36:00 UTC"
I want to extract the time and save it thats it
After doing this the new variables created comes with 2 hours more!! and thats exactly because I have at the moment GMT+2 in my machine! if I change my timezone, the numbers of hours substracted added change accordingly. What is going on!?
You have to make your own function to parse the date-string.
void OnStart() { string excel_date = "2018-04-10 15:36:00 UTC"; Alert(TimeToString(parseExcelDateString(excel_date))); } datetime parseExcelDateString(const string date) { MqlDateTime res; res.year = (int)StringSubstr(date,0,4); res.mon = (int)StringSubstr(date,5,2); res.day = (int)StringSubstr(date,8,2); res.hour = (int)StringSubstr(date,11,2); res.min = (int)StringSubstr(date,14,2); res.sec = (int)StringSubstr(date,17,2); return StructToTime(res); }
Yeah I did that, but why that was happening?
You should check the documentation :
The function converts a string containing time or date in "yyyy.mm.dd [hh:mi]" format into datetime type.
Your CSV string is using '-' separator, so the conversion function can't recognize it.

- docs.mql4.com

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello I have a .csv with times as strings in the format:
"2018-04-10 15:36:00 UTC"
I want to extract the time and save it thats it
After doing this the new variables created comes with 2 hours more!! and thats exactly because I have at the moment GMT+2 in my machine! if I change my timezone, the numbers of hours substracted added change accordingly. What is going on!?