formatDate

This commit is contained in:
tangly1024.com
2023-06-28 11:36:23 +08:00
parent a8a6bba283
commit 8fcc75f99e

View File

@@ -5,7 +5,7 @@
* @returns {string}
*/
export default function formatDate (date, local) {
if (!date) return ''
if (!date || !local) return date || ''
const d = new Date(date)
const options = { year: 'numeric', month: 'short', day: 'numeric' }
const res = d.toLocaleDateString(local, options)