Union Types
You can use a union type when declaring variables.
let month: string | number = currentTime.getMonth();
if (month < 10) {
month="0" + month;
}
Template literals (ES6+)
Alternatively you can create a new variable and use a template literal
const paddedMonth: string = `0${month}`;
Your string concatenation then turns into this for example:
str = `${year}-${paddedMonth}-${day} ${hours}:${minutes}:${seconds} `;
Much more readable, IMO.