Skip to content

Commit

Permalink
fix: put timezone offset into date
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgoff committed Dec 5, 2024
1 parent b2bc0ad commit d8743c5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,15 @@ export const useDateString = (date, isShort = false) => {
const localeInfo = useGlobalData("localeInfo");
const locale = localeInfo.language || fallbackLng;
const newDate = new Date(date);
newDate.setTime(newDate.getTime() + newDate.getTimezoneOffset() * 60 * 1000);
const options = {
year: "numeric",
month: `${isShort ? "short" : "long"}`,
month: isShort ? "short" : "long",
day: "numeric",
};
let dateString = newDate.toLocaleString(locale, options);
isShort && (dateString = dateString.replace(",", ""));

return dateString;
};

Expand Down

0 comments on commit d8743c5

Please sign in to comment.