]> BookStack Code Mirror - bookstack/blob - resources/js/services/dates.js
Dropzone: Swapped fetch for XHR for progress tracking
[bookstack] / resources / js / services / dates.js
1 export function getCurrentDay() {
2     const date = new Date();
3     const month = date.getMonth() + 1;
4     const day = date.getDate();
5
6     return `${date.getFullYear()}-${(month > 9 ? '' : '0') + month}-${(day > 9 ? '' : '0') + day}`;
7 }
8
9 export function utcTimeStampToLocalTime(timestamp) {
10     const date = new Date(timestamp * 1000);
11     const hours = date.getHours();
12     const mins = date.getMinutes();
13     return `${(hours > 9 ? '' : '0') + hours}:${(mins > 9 ? '' : '0') + mins}`;
14 }
15
16 export function formatDateTime(date) {
17     const month = date.getMonth() + 1;
18     const day = date.getDate();
19     const hours = date.getHours();
20     const mins = date.getMinutes();
21
22     return `${date.getFullYear()}-${(month > 9 ? '' : '0') + month}-${(day > 9 ? '' : '0') + day} ${(hours > 9 ? '' : '0') + hours}:${(mins > 9 ? '' : '0') + mins}`;
23 }