From 74a41caff6e7274c6926f5ae26b4180c920bb3dc Mon Sep 17 00:00:00 2001 From: jak1 Date: Sun, 1 Aug 2021 23:11:24 +0200 Subject: fixed timestamp formating --- app.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/app.js b/app.js index d219310..5862d80 100644 --- a/app.js +++ b/app.js @@ -302,15 +302,22 @@ joinArgs = function(argsList, remArgsBefore, remArgsAfter){ return res; } -// gets the current (weird formated) timestamp (FIXME later...) +// gets the current (weird formated) timestamp getTimeStamp = function(){ var date_ob = new Date(); - day = date_ob.getDate(); - month = date_ob.getMonth(); + day = addLeadingZero(date_ob.getDate()); + month = addLeadingZero(date_ob.getMonth()); year = date_ob.getFullYear(); - hours = date_ob.getHours(); - minutes = date_ob.getMinutes(); - seconds = date_ob.getSeconds(); + hours = addLeadingZero(date_ob.getHours()); + minutes = addLeadingZero(date_ob.getMinutes()); + seconds = addLeadingZero(date_ob.getSeconds()); return (year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds); +} + +// formats number (n) to 2-digit +addLeadingZero = function(n){ + if (n <= 9) + return "0"+n; + return n; } \ No newline at end of file -- cgit v1.2.3-70-g09d2