Files
discourse-subscriptions/assets/javascripts/discourse/helpers/format-unix-date.js
T

17 lines
400 B
JavaScript
Raw Normal View History

import { htmlSafe } from "@ember/template";
2024-01-16 17:51:44 +01:00
import { autoUpdatingRelativeAge } from "discourse/lib/formatter";
2019-11-01 12:30:19 +11:00
export default function formatUnixDate(timestamp) {
2019-11-01 12:30:19 +11:00
if (timestamp) {
const date = new Date(moment.unix(timestamp).format());
return new htmlSafe(
2019-11-01 12:30:19 +11:00
autoUpdatingRelativeAge(date, {
format: "medium",
title: true,
2020-09-16 09:53:50 -05:00
leaveAgo: true,
2019-11-01 12:30:19 +11:00
})
);
}
}