Chatwoot/app/javascript/dashboard/mixins/time.js
2022-01-07 16:16:49 +05:30

16 lines
489 B
JavaScript

import fromUnixTime from 'date-fns/fromUnixTime';
import format from 'date-fns/format';
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);
return formatDistanceToNowStrict(unixTime, { addSuffix: true });
},
},
};