2023-03-14 11:00:40 +00:00
|
|
|
import crypto from 'crypto';
|
|
|
|
|
2023-04-15 10:30:02 +00:00
|
|
|
export function randomID(bytes = 16) {
|
|
|
|
return crypto.randomBytes(bytes).toString('hex');
|
2023-04-29 18:30:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export function formatTime() {
|
|
|
|
// MM/DD/YYYY HH:MM:SS AM/PM
|
|
|
|
const date = new Date();
|
|
|
|
let hours = date.getHours();
|
|
|
|
const minutes = date.getMinutes();
|
|
|
|
const seconds = date.getSeconds();
|
|
|
|
const ampm = hours >= 12 ? 'PM' : 'AM';
|
|
|
|
hours %= 12;
|
|
|
|
const month = date.getMonth() + 1;
|
|
|
|
const day = date.getDate();
|
|
|
|
const year = date.getFullYear();
|
|
|
|
return `${month}/${day}/${year} ${hours}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')} ${ampm}`;
|
2023-03-14 11:00:40 +00:00
|
|
|
}
|