From c10266159016da0a53c93ef7f1350a6d225b7c09 Mon Sep 17 00:00:00 2001 From: Olivier PEREZ Date: Tue, 26 Apr 2016 23:29:22 +0200 Subject: [PATCH] LeftPad day/month/year --- js/app/date_poll.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/js/app/date_poll.js b/js/app/date_poll.js index f76ee26..a9f15d6 100644 --- a/js/app/date_poll.js +++ b/js/app/date_poll.js @@ -68,9 +68,9 @@ $(document).ready(function () { var formatDate = function (date, format) { return format - .replace('%d', date.getDate()) - .replace('%m', date.getMonth() + 1) - .replace('%Y', date.getFullYear()); + .replace('%d', ("00" +date.getDate()).slice(-2)) + .replace('%m', ("00" + (date.getMonth() + 1)).slice(-2)) + .replace('%Y', ("0000" + date.getFullYear()).slice(-4)); }; function newDateFields(dateStr) {