Timeago.js is a very concise, lightweight, less than 2KB Javascript library that converts datetime time into a descriptive string similar to * * * time, for example: "3 hours Ago".
Localization support, the default comes with Chinese and English language;
Before xxx time, after xxx time;
Support automatic real-time update;
Support NPM mode and browser script mode;
Perfect test case, good execution;
HTML:
<div class= "Time" datetime= "2018-03-2 17:13:00" ></div>
Js:
<script src= "Https://cdn.bootcss.com/timeago.js/3.0.2/timeago.js" ></script>
<script>
Do not update automatically
var timeagoinstance = Timeago ();//Instance
var time = Timeagoinstance.format (' 2018-03-2 17:13:00 ', ' zh_cn ');
Console.log (time);
Automatic Updates
var timeagoinstance = Timeago ();//Instance
Timeagoinstance.render (Document.queryselectorall ('. Time '), ' zh_cn ');
</script>
timeago.js-Time Display Plugin