zoukankan      html  css  js  c++  java
  • moment.js

    日期格式化

    moment().format('MMMM Do YYYY, h:mm:ss a'); // 十二月 22日 2015, 9:26:01 上午
    moment().format('dddd');                    // 星期二
    moment().format("MMM Do YY");               // 12月 22日 15
    moment().format('YYYY [escaped] YYYY');     // 2015 escaped 2015
    moment().format();                          // 2015-12-22T09:26:01+08:00

    相对时间

    moment("20111031", "YYYYMMDD").fromNow(); // 4 年前
    moment("20120620", "YYYYMMDD").fromNow(); // 4 年前
    moment().startOf('day').fromNow();        // 9 小时前
    moment().endOf('day').fromNow();          // 15 小时内
    moment().startOf('hour').fromNow();       // 26 分钟前

    日历时间

    moment().subtract(10, 'days').calendar(); // 2015年12月12日
    moment().subtract(6, 'days').calendar();  // 上周三上午9点26
    moment().subtract(3, 'days').calendar();  // 上周六上午9点26
    moment().subtract(1, 'days').calendar();  // 昨天上午9点26分
    moment().calendar();                      // 今天上午9点26分
    moment().add(1, 'days').calendar();       // 明天上午9点26分
    moment().add(3, 'days').calendar();       // 本周五上午9点26
    moment().add(10, 'days').calendar();      // 2016年1月1日

    多语言支持

    moment().format('L');    // 2015-12-22
    moment().format('l');    // 2015-12-22
    moment().format('LL');   // 2015年12月22日
    moment().format('ll');   // 2015年12月22日
    moment().format('LLL');  // 2015年12月22日上午9点26分
    moment().format('lll');  // 2015年12月22日上午9点26分
    moment().format('LLLL'
  • 相关阅读:
    HelloWorld入门程序
    list的几种遍历方式
    遍历map的几种方法
    Java动态代理
    七月七日学习记录
    七月六日学习报告
    钢镚儿使用体验
    TD tree 使用体验
    学习笔记154—Matlab 如何写入txt?
    学习笔记153—matlab中小数如何取整?
  • 原文地址:https://www.cnblogs.com/emmaBlogs/p/5065583.html
Copyright © 2011-2022 走看看