You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/pages/blog/date-formatting-nextjs.mdx
+4-4
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ import {Tweet} from 'react-tweet';
6
6
7
7
# Reliable date formatting in Next.js
8
8
9
-
<small>Sep 19, 2024 · by Jan Amann</small>
9
+
<small>Sep 25, 2024 · by Jan Amann</small>
10
10
11
11
Let's take a look at the following component:
12
12
@@ -159,7 +159,7 @@ Well, are we done now?
159
159
160
160
## Where are we?
161
161
162
-
We've carefully ensured that our app is free of hydration mismatches and have established consistent time handling across all components. But what happens if we decide one day that we don't want to render a relative time like "2 days ago", but a specific date like "Sep 19, 2024"?
162
+
We've carefully ensured that our app is free of hydration mismatches and have established consistent time handling across all components. But what happens if we decide one day that we don't want to render a relative time like "2 days ago", but a specific date like "Sep 25, 2024"?
163
163
164
164
```tsx
165
165
import {format} from'date-fns';
@@ -229,7 +229,7 @@ As browsers don't include the time zone of the user in an HTTP request, one way
229
229
So far, we've assumed that our app will be used by American English users, with dates being formatted like:
230
230
231
231
```
232
-
Sep 19, 2024
232
+
Sep 25, 2024
233
233
```
234
234
235
235
Our situation gets interesting again, once we consider that the date format is not universal. In Great Britain, for instance, the same date might be formatted as "19 Sept 2024", with the day and month being swapped.
@@ -306,7 +306,7 @@ export default function BlogPostPublishedDate({published}: Props) {
0 commit comments