Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
client: create a date formatter utility
Adorian Doranb097a8fc3702
diff --git a/src/public/app/utils/formatters.js b/src/public/app/utils/formatters.jsnew file mode 100644index 0000000000..f59e3144f2--- /dev/null+++ b/src/public/app/utils/formatters.js@@ -0,0 +1,14 @@+/**+ * Formats the given date to a string based on the current locale.+ * @param {Date | number} date+ * @param {"full" | "long" | "medium" | "short" | undefined} dateStyle+ * @param {"full" | "long" | "medium" | "short" | undefined} tiemStyle+ */+export function formatDate(date, dateStyle = "medium", tiemStyle = "medium") {+ const formatter = new Intl.DateTimeFormat(navigator.language, {+ dateStyle: "medium",+ timeStyle: "medium"+ });++ return formatter.format(date);+}\ No newline at end of file