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

17 lines
400 B
JavaScript
Raw Normal View History

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