First off i'd like to apologize for the noobish question.
Please take a look at the following code:
var dt = new Date(t*1000);
var m = "0" + dt.getMinutes();
When outputted, it can give us one of the following results, depending of the t
variable (aka unix time):
m = 054 // 54 minutes
m = 03 // 3 minutes
As you can see, if theres too many minutes, the formatting becomes broken. To fix this, we must call a function to only keep the two last characters. To do this, we'll use the following code:
var m = "0" + dt.getMinutes();
m = m.substr(-2);
Which can output:
m = 54 // 54 minutes
m = 3 // 03 minutes
Good! We fixed the problem, right? Well, I think that setting the variable two times in a row is stupid. I tried:
var m = "0" + dt.getMinutes().substr(-2);
But I get the following error:
TypeError: dt.getMinutes(...).substr is not a function
Is there a one liner way to do this?