-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdateFunctions.js
26 lines (24 loc) · 1 KB
/
dateFunctions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
export function convertDateFormat(dateString) {
const date = new Date(dateString);
const day = date.getDate();
const month = date.toLocaleString('default', { month: 'short' });
const formattedDate = `${day} ${month}`;
return formattedDate;
}
export function getDateAndTime(dateString) {
const date = new Date(dateString);
const day = String(date.getDate()).padStart(2, '0');
const month = date.toLocaleString('default', { month: 'short' });
const year = date.getFullYear();
const hours = String(date.getHours()).padStart(2, '0');
const minutes = String(date.getMinutes()).padStart(2, '0');
const formattedDateTime = `${day} ${month} ${year} - ${hours}:${minutes}`;
return formattedDateTime;
}
export function getTime(dateString) {
const date = new Date(dateString);
const hours = String(date.getHours()).padStart(2, '0');
const minutes = String(date.getMinutes()).padStart(2, '0');
const formattedTime = `${hours}:${minutes}`;
return formattedTime;
}