Chatwoot/app/javascript/dashboard/mixins/time.js

17 lines
489 B
JavaScript
Raw Normal View History

import fromUnixTime from 'date-fns/fromUnixTime';
import format from 'date-fns/format';
2022-01-07 10:46:49 +00:00
import formatDistanceToNowStrict from 'date-fns/formatDistanceToNowStrict';
export default {
methods: {
messageStamp(time, dateFormat = 'h:mm a') {
const unixTime = fromUnixTime(time);
return format(unixTime, dateFormat);
},
dynamicTime(time) {
const unixTime = fromUnixTime(time);
2022-01-07 10:46:49 +00:00
return formatDistanceToNowStrict(unixTime, { addSuffix: true });
},
},
};