• moment.js(日期处理类库)的使用


    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>moment.js(日期处理类库)的使用</title>
        <script src="moment.js"></script>
        <script src="moment-with-locales.js"></script>
    </head>
    <body>
        <script>
            /*
            moment.js version : 2.18.1
            
            Format Dates
            moment().format('MMMM Do YYYY, h:mm:ss a'); // September 6th 2017, 4:17:22 pm
            moment().format('dddd');                    // Wednesday
            moment().format("MMM Do YY");               // Sep 6th 17
            moment().format('YYYY [escaped] YYYY');     // 2017 escaped 2017
            moment().format();                          // 2017-09-06T16:17:22+08:00
            Relative Time
            moment("20111031", "YYYYMMDD").fromNow(); // 6 years ago
            moment("20120620", "YYYYMMDD").fromNow(); // 5 years ago
            moment().startOf('day').fromNow();        // 16 hours ago
            moment().endOf('day').fromNow();          // in 8 hours
            moment().startOf('hour').fromNow();       // 17 minutes ago
            Calendar Time
            moment().subtract(10, 'days').calendar(); // 08/27/2017
            moment().subtract(6, 'days').calendar();  // Last Thursday at 4:17 PM
            moment().subtract(3, 'days').calendar();  // Last Sunday at 4:17 PM
            moment().subtract(1, 'days').calendar();  // Yesterday at 4:17 PM
            moment().calendar();                      // Today at 4:17 PM
            moment().add(1, 'days').calendar();       // Tomorrow at 4:17 PM
            moment().add(3, 'days').calendar();       // Saturday at 4:17 PM
            moment().add(10, 'days').calendar();      // 09/16/2017
            Multiple Locale Support
            moment.locale();         // en
            moment().format('LT');   // 4:17 PM
            moment().format('LTS');  // 4:17:22 PM
            moment().format('L');    // 09/06/2017
            moment().format('l');    // 9/6/2017
            moment().format('LL');   // September 6, 2017
            moment().format('ll');   // Sep 6, 2017
            moment().format('LLL');  // September 6, 2017 4:17 PM
            moment().format('lll');  // Sep 6, 2017 4:17 PM
            moment().format('LLLL'); // Wednesday, September 6, 2017 4:17 PM
            moment().format('llll');*/
    
            console.log(moment.locale('zh-cn'));
            console.log(moment().format('L'));
            console.log(moment().format('YYYY-MM-DD'));
            console.log(moment("/Date(1198908717056)/")); 
            console.log(moment("/Date(1198908717056)/")._d); 
            console.log(moment(moment("/Date(1198908717056)/")._d).format('YYYY-MM-DD')); 
        </script>
    </body>
    </html>
    业精于勤荒于嬉,行成于思毁于随
  • 相关阅读:
    EventBus--介绍
    EventBus--出现的问题
    File存对象--android 的File存储到SD卡();
    SharePrecences--(json+sharePrecences)存list 或对象
    缓存AsimpleCache -- 解决Android中Sharedpreferences无法存储List数据/ASimpleCache
    ViewPager--左右可滑动的
    git之win安装git和环境配置及常用命令总结
    mySql事务_ _Java中怎样实现批量删除操作(Java对数据库进行事务处理)?
    eclispe---快捷键设置
    bug_ _org.json.JSONException: End of input at character 0 of
  • 原文地址:https://www.cnblogs.com/qixianchuan/p/11162799.html
Copyright © 2020-2023  润新知