0

See the following code I tried:

MqlDateTime time;
TimeToStruct(TimeCurrent(),time);
string currenttime=IntegerToString(time.year)+"-0"+
                      IntegerToString(time.mon)+"-"+
                      IntegerToString(time.day)+ " "+
                      IntegerToString(time.hour)+ ":"+
                      IntegerToString(time.min)+ ":00";

The output of the following was: 2018-7-25 15:8:00 where I was expecting the output as 2018-07-25 15:08:00, that is in 2 values the month and the min. But it is not converting the zero. The date time what I am giving is in the format 2018-07-25 15:08:00, which is I am expecting to get after converting to string. But got something else.

Please help me.

1 Answer 1

1

Why do you think the minutes should have zero before it? according to the code you have, seems minutes are not without leading zero.

Anyway if you do not like TimeToString, try StringFormat.

string output=StringFormat("%04d-%02d-%02d %02d:%02d:00", 
               time.year,time.mon,time.day,time.hour,time.min);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.