Created
April 24, 2024 17:57
-
-
Save abdelfattahradwan/113a79cdedbc3d33a58f5b8b3638de9c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { browser } from "$app/environment"; | |
export default function formatDateTime(dateTime: Date): string { | |
return browser && window.navigator | |
? new Intl.DateTimeFormat(window.navigator.language, { | |
dateStyle: "long", | |
timeStyle: "short", | |
}).format(dateTime) | |
: dateTime.toLocaleString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment