1
0
mirror of https://github.com/alice-lg/alice-lg.git synced 2024-05-11 05:55:03 +00:00
alice-lg-alice-lg/client/components/datetime/relative-timestamp.jsx
2018-10-03 15:30:41 +02:00

17 lines
364 B
JavaScript

import React from 'react'
import moment from 'moment'
export default class RelativeTimestamp extends React.Component {
render() {
const tsMs = this.props.value / 1000.0 / 1000.0; // nano -> micro -> milli
const now = moment.utc()
const rel = now.subtract(tsMs, 'ms');
return (
<span>{rel.fromNow(this.props.suffix)}</span>
);
}
}