时间表达转换 timeago.js

码农软件 · 软件分类 · 网页开发工具 · 2019-03-21 05:58:38

软件介绍

timeago.js 是一个非常简洁、轻量级、小于 2kb 的很简洁的Javascript库,用来将datetime时间转化成类似于 "***时间前"的描述字符串,例如:“3小时前”。

官网地址:http://timeago.org/

格式之后的效果为:

  • just now

  • 12 seconds ago

  • 3 minutes ago

  • 2 hours ago

  • 24 days ago

  • 6 months ago

  • 2 years ago

  • in 12 seconds

  • in 3 minutes

  • in 2 hours

  • in 24 days

  • in 6 months

  • in 2 years

特点:
1. 本地化语言,默认支持中文和英文,一般够用;
2. 支持 几x前,几x后 两种方式;
3. npm和浏览器script均支持;
4. 完善的自动化测试case;
5. 非常非常小,2kb,gzip之后更小;

使用:

import timeago from 'timeago.js';

或者

<script src="dist/timeago.min.js"></script>
var timeago = timeago();
timeago.format('2016-06-12')

即可使用。可以传入Date类型,也可以是字符串类型,同时也支持timestamp。
更多使用方法,请到项目主页。

本文地址:https://www.codercto.com/soft/d/1803.html

Beginning ASP.NET 4 in C# and Vb

Beginning ASP.NET 4 in C# and Vb

Imar Spaanjaars / Wrox / 2010-3-19 / GBP 29.99

This book is for anyone who wants to learn how to build rich and interactive web sites that run on the Microsoft platform. With the knowledge you gain from this book, you create a great foundation to ......一起来看看 《Beginning ASP.NET 4 in C# and Vb》 这本书的介绍吧!

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具