BookStackApp_BookStack/resources/js/services/dates.js
Dan Brown e711290d8b
Ran eslint fix on existing codebase
Had to do some manual fixing of the app.js file due to misplaced
comments
2023-04-18 22:20:02 +01:00

24 lines
840 B
JavaScript

export function getCurrentDay() {
const date = new Date();
const month = date.getMonth() + 1;
const day = date.getDate();
return `${date.getFullYear()}-${(month > 9 ? '' : '0') + month}-${(day > 9 ? '' : '0') + day}`;
}
export function utcTimeStampToLocalTime(timestamp) {
const date = new Date(timestamp * 1000);
const hours = date.getHours();
const mins = date.getMinutes();
return `${(hours > 9 ? '' : '0') + hours}:${(mins > 9 ? '' : '0') + mins}`;
}
export function formatDateTime(date) {
const month = date.getMonth() + 1;
const day = date.getDate();
const hours = date.getHours();
const mins = date.getMinutes();
return `${date.getFullYear()}-${(month > 9 ? '' : '0') + month}-${(day > 9 ? '' : '0') + day} ${(hours > 9 ? '' : '0') + hours}:${(mins > 9 ? '' : '0') + mins}`;
}