Use of the jquery time format plugin-moment.js
Moment.js plug-in use, the use of the page before the introduction of the corresponding JS file:
Detailed operation is visible moment Chinese official website: http://momentjs.cn/
Date formatting
moment().format(‘MMMM Do YYYY, h:mm:ss a‘); // 四月 14日 2017, 1:41:52 下午moment().format(‘dddd‘); // 星期五moment().format("MMM Do YY"); // 4月 14日 17moment().format(‘YYYY [escaped] YYYY‘); // 2017 escaped 2017moment().format(); // 2017-04-14T13:41:52+08:00
Relative time
moment("20111031", "YYYYMMDD").fromNow(); // 5 年前moment("20120620", "YYYYMMDD").fromNow(); // 5 年前moment().startOf(‘day‘).fromNow(); // 14 小时前moment().endOf(‘day‘).fromNow(); // 10 小时内moment().startOf(‘hour‘).fromNow(); // 42 分钟前
Calendar Time
Moment (). Subtract (10,' days '). Calendar (); //April 4, 2017 Moment (). Subtract (6, ' days '). Calendar (); //Saturday 1 o'clock in the afternoon 41moment (). Subtract (3, ' days '). Calendar (); //This Tuesday 1 o'clock in the afternoon 41moment (). Subtract (1, ' days '). Calendar (); //Yesterday 1:41 P.M. Moment (). Calendar (); //Today 1:41 P.M. Moment (). Add (1, ' days '). Calendar (); //Tomorrow 1:41 P.M. Moment (). Add (3, ' days '). Calendar (); //Next Monday 1 o'clock in the afternoon 41moment (). Add (Ten, ' days '). Calendar (); //April 24, 2017
Multi-lingual support
moment().format(‘L‘); // 2017-04-14moment().format(‘l‘); // 2017-04-14moment().format(‘LL‘); // 2017年4月14日moment().format(‘ll‘); // 2017年4月14日moment().format(‘LLL‘); // 2017年4月14日下午1点41分moment().format(‘lll‘); // 2017年4月14日下午1点41分moment().format(‘LLLL‘); // 2017年4月14日星期五下午1点41分moment().format(‘llll‘); // 2017年4月14日星期五下午1点41分
Use of the jquery time format plugin-moment.js