jan/web-client/app/_utils/datetime.ts
hiento09 86f0ffc7d1
Chore/disable submodule (#56)
* Chore disable git submodule for web-client and app-backend

* Chore add newest source code of app-backend and web-client

---------

Co-authored-by: Hien To <tominhhien97@gmail.com>
2023-09-05 16:29:07 +07:00

16 lines
454 B
TypeScript

export const isToday = (timestamp: number) => {
const today = new Date();
return today.setHours(0, 0, 0, 0) == new Date(timestamp).setHours(0, 0, 0, 0);
};
export const displayDate = (timestamp: number) => {
let displayDate = new Date(timestamp).toLocaleString();
if (isToday(timestamp)) {
displayDate = new Date(timestamp).toLocaleTimeString(undefined, {
hour: "2-digit",
minute: "2-digit",
});
}
return displayDate;
};