Adding 0 to Minutes below 10

[Deleted]  
Minute() outputs the current minute but it only does 1 digit for those under ten, so my time would look like this 1:9 and (of course) I'd like it to read 1:09. How do I do this for every minute under 10?
 
mixtermind:
Minute() outputs the current minute but it only does 1 digit for those under ten, so my time would look like this 1:9 and (of course) I'd like it to read 1:09. How do I do this for every minute under 10?

offtop my head!


int h=hour();
int m=minute();
if(m<10)
{
string n="0"+m;
m=strtointeger(n);}
Alert(h+":"+m);
[Deleted]  
c0d3:

offtop my head!



I ended up translating brookertime into minutes because I needed a simple comparison between indicator time and broker time. Total minutes in the day is the best way to do this. Thinking about it there would be a glitch between 12:00 AM broker time and 12:07 AM broker time because my threshold of 8 minutes would end up being a negative number. I can live with this though, I don't plan I trading at that time of the day anyway.

[Deleted]  

I actually ended up having to use epoch time because strTime seems to output local time instead of server time:


int CheckTime()
{
//Have to go through this junk because strtime uses local time and not server time
int y=Year();
int M=Month();
int d=Day();
int h=Hour();
int m=Minute();
if(M<10)
{
string N="0"+M;
M=StrToInteger(N);
}
if(d<10)
{
string e="0"+d;
d=StrToInteger(e);
}
if(m<10)
{
string n="0"+m;
m=StrToInteger(n);
}
//Convert Time to Seconds since 1970 - 2009.04.06 1:05
string times=StringConcatenate(y,".",M,".",d," ",h,":",m);
int brokerseconds=StrToTime(times);
return (brokerseconds);
}

 
mixtermind:

I actually ended up having to use epoch time because strTime seems to output local time instead of server time:


int CheckTime()
{
//Have to go through this junk because strtime uses local time and not server time
int y=Year();
int M=Month();
int d=Day();
int h=Hour();
int m=Minute();
if(M<10)
{
string N="0"+M;
M=StrToInteger(N);
}
if(d<10)
{
string e="0"+d;
d=StrToInteger(e);
}
if(m<10)
{
string n="0"+m;
m=StrToInteger(n);
}
//Convert Time to Seconds since 1970 - 2009.04.06 1:05
string times=StringConcatenate(y,".",M,".",d," ",h,":",m);
int brokerseconds=StrToTime(times);
return (brokerseconds);
}

if you use this https://docs.mql4.com/dateandtime/TimeCurrent, it will give you the same integer, seconds passed since 1970... on brokers servers.

 

Does the following give you what you want?


TimeToStr(TimeLocal(),TIME_MINUTES);


Or use TimeCurrent() as appropriate.