You can construct a Date instance from a timestamp value and then use the various accessor methods (.getDate()
, .getMonth()
, .getFullYear()
etc) to format the date according to your needs.
So for example:
var savedDate = new Date(db_time);
to make a Date instance. Then it's helpful to have a function to produce two-digit zero-prefixed numbers:
function d2( n ) {
return (n < 10 ? "0" : "") + n;
}
Then a DD-MM-YYYY date can be built:
var ddmmyy = d2(savedDate.getDate()) + "-" + d2(savedDate.getMonth() + 1) + "-" + savedDate.getFullYear();
(The month values from Date instances run 0 to 11, thus the need to add 1.)