Add zero before days only when single digit

This commit is contained in:
Brian Miyaji
2018-10-23 12:19:38 +11:00
parent e34bce1576
commit f013f93ed1

View File

@@ -42,7 +42,7 @@ function sp_viewport() {
var seconds = Math.floor((distance % (1000 * 60)) / 1000); var seconds = Math.floor((distance % (1000 * 60)) / 1000);
// Output the result // Output the result
$this.html("<span>"+('0' + days).slice(-3)+" <small>" + localized_strings.days + "</small></span> " $this.html("<span>"+(days < 10 ? '0' + days : days)+" <small>" + localized_strings.days + "</small></span> "
+ "<span>"+('0' + hours).slice(-2)+" <small>" + localized_strings.hrs + "</small></span> " + "<span>"+('0' + hours).slice(-2)+" <small>" + localized_strings.hrs + "</small></span> "
+ "<span>"+('0' + minutes).slice(-2)+" <small>" + localized_strings.mins + "</small></span> " + "<span>"+('0' + minutes).slice(-2)+" <small>" + localized_strings.mins + "</small></span> "
+ "<span>"+('0' + seconds).slice(-2)+" <small>" + localized_strings.secs + "</small></span>" ); + "<span>"+('0' + seconds).slice(-2)+" <small>" + localized_strings.secs + "</small></span>" );