• 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>
    业精于勤荒于嬉,行成于思毁于随
  • 相关阅读:
    java使用jsp servlet来防止csrf 攻击的实现方法
    Fiddler抓包6-get请求(url详解)
    Fiddler抓包5-接口测试(Composer)
    Fiddler抓包4-工具介绍(request和response)
    Fiddler抓包3-查看get与post请求
    Selenium2+python自动化60-异常后截图(screenshot)
    Selenium2+python自动化59-数据驱动(ddt)
    Selenium2+python自动化58-读取Excel数据(xlrd)
    Selenium2+python自动化57-捕获异常(NoSuchElementException)
    Selenium2+python自动化56-unittest之断言(assert)
  • 原文地址:https://www.cnblogs.com/qixianchuan/p/11162799.html
Copyright © 2020-2023  润新知