Use of the jquery time format plugin-moment.js

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.