salix/loopback/util/date.js

26 lines
480 B
JavaScript
Raw Normal View History

2021-02-05 07:05:57 +00:00
/**
* Transforms a UTC date to string without datetime.
*
* @param {date} date Date to format
* @return {String} Formatted date string
*/
function toString(date) {
date = new Date(date);
let day = date.getDate();
let month = date.getMonth() + 1;
let year = date.getFullYear();
if (day < 10)
day = `0${day}`;
if (month < 10)
month = `0${month}`;
return `${day}-${month}-${year}`;
}
module.exports = {
toString: toString
};