Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

refactor: change formatDate utils func

Marc Seitz1a2b3fd63b6f
diff --git a/app/(static)/blog/[slug]/page.tsx b/app/(static)/blog/[slug]/page.tsx
index faa8035f..7061af34 100644
--- a/app/(static)/blog/[slug]/page.tsx
+++ b/app/(static)/blog/[slug]/page.tsx
@@ -3,7 +3,6 @@ import { ContentBody } from "@/components/mdx/post-body";
import { notFound } from "next/navigation";
import Link from "next/link";
import BlurImage from "@/components/blur-image";
-import { formattedDate } from "@/lib/utils";
export default async function BlogPage({
params,
@@ -19,7 +18,7 @@ export default async function BlogPage({
<div className="flex max-w-screen-sm flex-col space-y-4 pt-16">
<div className="flex items-center space-x-4">
<time dateTime={post.data.publishedAt} className="text-sm">
- {formattedDate(post.data.publishedAt)}
+ {formatDate(post.data.publishedAt)}
</time>
</div>
<h1 className="text-4xl md:text-6xl text-balance">
diff --git a/content/blog/hello-world.mdx b/content/blog/hello-world.mdx
index 7fa6eddf..b8687dee 100644
--- a/content/blog/hello-world.mdx
+++ b/content/blog/hello-world.mdx
@@ -1,6 +1,6 @@
---
title: Hello World Hello World Hello World
-publishedAt: "2024-02-14"
+publishedAt: 2024-02-14
summary: This is a hello world post This is a hello world post This is a hello world post
author: Marc Seitz
slug: hello-world
diff --git a/lib/utils.ts b/lib/utils.ts
index 268d3643..9af91d84 100644
--- a/lib/utils.ts
+++ b/lib/utils.ts
@@ -217,11 +217,12 @@ export const getFirstAndLastDay = (day: number) => {
}
};
-export const formattedDate = (date: Date) => {
- return new Date(date).toLocaleDateString("en-US", {
- month: "short",
- day: "2-digit",
+export const formatDate = (dateString: string) => {
+ return new Date(dateString).toLocaleDateString("en-US", {
+ day: "numeric",
+ month: "long",
year: "numeric",
+ timeZone: "UTC",
});
};
diff --git a/pages/settings/billing.tsx b/pages/settings/billing.tsx
index ab9e2c1b..4530d2b1 100644
--- a/pages/settings/billing.tsx
+++ b/pages/settings/billing.tsx
@@ -5,7 +5,7 @@ import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { useTeam } from "@/context/team-context";
import { useBilling } from "@/lib/swr/use-billing";
-import { cn, formattedDate, getFirstAndLastDay } from "@/lib/utils";
+import { cn } from "@/lib/utils";
import Link from "next/link";
import { useRouter } from "next/router";
import { useEffect, useState } from "react";