javascript format date time string hh mm ss code example Example: h = (h < 10) ? "0" + h : h; h = (h < 10) ? "0" + h : h;