Ability to post in Forum
This commit is contained in:
24
server/util.js
Normal file
24
server/util.js
Normal file
@@ -0,0 +1,24 @@
|
||||
global.ServerError = class extends Error {
|
||||
constructor(status, msg) {
|
||||
super(msg);
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
|
||||
global.currentTime = function () {
|
||||
const now = new Date();
|
||||
|
||||
const month = String(now.getMonth() + 1).padStart(2, "0");
|
||||
const day = String(now.getDate()).padStart(2, "0");
|
||||
const year = now.getFullYear();
|
||||
|
||||
let hours = now.getHours();
|
||||
const ampm = hours >= 12 ? "pm" : "am";
|
||||
hours = hours % 12 || 12; // convert to 12-hour format
|
||||
|
||||
const minutes = String(now.getMinutes()).padStart(2, "0");
|
||||
const seconds = String(now.getSeconds()).padStart(2, "0");
|
||||
const ms = String(now.getMilliseconds()).padStart(4, "0"); // 4-digit like "5838"
|
||||
|
||||
return `${month}.${day}.${year}-${hours}:${minutes}:${seconds}${ms}${ampm}`;
|
||||
}
|
||||
Reference in New Issue
Block a user