mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 11:01:42 +08:00
Add util function formatDatetime
This commit is contained in:
@@ -0,0 +1,14 @@
|
|||||||
|
const formatDatetime = (datetime: string) => {
|
||||||
|
const myDatetime = new Date(datetime);
|
||||||
|
return (
|
||||||
|
myDatetime.toLocaleDateString([], {
|
||||||
|
year: "numeric",
|
||||||
|
month: "long",
|
||||||
|
day: "numeric",
|
||||||
|
}) +
|
||||||
|
" | " +
|
||||||
|
myDatetime.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" })
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default formatDatetime;
|
||||||
Reference in New Issue
Block a user