Skip to content

Commit

Permalink
avoid timezone entirely
Browse files Browse the repository at this point in the history
  • Loading branch information
stevector committed Nov 21, 2024
1 parent 3ac9d97 commit 87b3e34
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/components/PublishedDate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ const PublishedDate = ({ dateString, className }) => {
// Turn ReleaseNoteData.frontmatter.published_date into a date object.
// And then format it as Month Day, Year.
// https://stackoverflow.com/questions/3552461/how-to-format-a-javascript-date
const date = new Date(`${dateString}T00:00:00Z`); // Interpret as UTC midnight
const options = { year: "numeric", month: "long", day: "numeric", timeZone: "UTC" }; // Format as UTC
const formattedDate = date.toLocaleDateString(undefined, options)

const [year, month, day] = dateString.split("-"); // Extract year, month, and day
const formattedDate = `${new Date(year, month - 1).toLocaleString('default', { month: 'long' })} ${parseInt(day)}, ${year}`;


return (
<div
Expand Down

0 comments on commit 87b3e34

Please sign in to comment.