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

17 lines
471 B
JavaScript
Raw Normal View History

import fromUnixTime from 'date-fns/fromUnixTime';
import format from 'date-fns/format';
import formatDistanceToNow from 'date-fns/formatDistanceToNow';
export default {
methods: {
messageStamp(time, dateFormat = 'h:mm a') {
const unixTime = fromUnixTime(time);
return format(unixTime, dateFormat);
},
dynamicTime(time) {
const unixTime = fromUnixTime(time);
return formatDistanceToNow(unixTime, { addSuffix: true });
},
},
};