zoukankan      html  css  js  c++  java
  • js new Date() 测试

    var t =  new Date().toString(); //t =  "Thu Oct 31 2019 11:36:57 GMT+0800 (中国标准时间)"
     var t1 = new Date();
     var data_arry =[];
     var that = new Date();
     data_arry.push(that.constructor());  // Thu Oct 31 2019 11:50:26 GMT+0800 (中国标准时间)"
    data_arry.push(that.getDate());  //31
    data_arry.push(that.getDay());  // 4
    data_arry.push(that.getFullYear()); //2019
    data_arry.push(that.getHours());  // 11
    data_arry.push(that.getMilliseconds()); // 401
    data_arry.push(that.getMinutes()); // 50
    data_arry.push(that.getMonth()); //9
    data_arry.push(that.getSeconds()); //26
    data_arry.push(that.getTime());  //1572493826401
    data_arry.push(that.getTimezoneOffset());  //-480
    data_arry.push(that.getUTCDate()); //31
    data_arry.push(that.getUTCDay());
    data_arry.push(that.getUTCFullYear());
    data_arry.push(that.getUTCHours());
    data_arry.push(that.getUTCMilliseconds());
    data_arry.push(that.getUTCMinutes());
    data_arry.push(that.getUTCMonth());
    data_arry.push(that.getUTCSeconds());
    data_arry.push(that.getYear());
    data_arry.push(that.setDate());
    data_arry.push(that.setFullYear());
    data_arry.push(that.setHours());
    data_arry.push(that.setMilliseconds());
    data_arry.push(that.setMinutes());
    data_arry.push(that.setMonth());
    data_arry.push(that.setSeconds());
    data_arry.push(that.setTime());
    data_arry.push(that.setUTCDate());
    data_arry.push(that.setUTCFullYear());
    data_arry.push(that.setUTCHours());
    data_arry.push(that.setUTCMilliseconds());
    data_arry.push(that.setUTCMinutes());
    data_arry.push(that.setUTCMonth());
    data_arry.push(that.setUTCSeconds());
    data_arry.push(that.setYear());
    data_arry.push(that.toDateString());
    data_arry.push(that.toGMTString());
    //data_arry.push(that.toISOString()); 报错
    data_arry.push(that.toJSON());
    data_arry.push(that.toLocaleDateString());
    data_arry.push(that.toLocaleString());
    data_arry.push(that.toLocaleTimeString());
    data_arry.push(that.toString());
    data_arry.push(that.toTimeString());
    data_arry.push(that.toUTCString());
    data_arry.push(that.valueOf());
        function get_nowtime() {
                var date = new Date();
                return (date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate());
            }
            console.log(get_nowtime());
            function get_nowtime() {
                function format(str) {
                    str += "";
                    if (str.length < 2) {
                        str = "0" + str;
                    }
                    return str;
                }
                var date = new Date();
                return (date.getFullYear() + '-' + format((date.getMonth() + 1)) + '-' + format(date.getDate()));
            }

     js  时间字符串转时间

          layui.use('laydate', function () {
                var laydate = layui.laydate;
                laydate.render({
                    elem: '#test1'
                     ,format: 'yyyy-MM-dd' //可任意组合,
                    , value: new Date(document.getElementById('test1').value) //必须遵循format参数设定的格式
                });
            });
  • 相关阅读:
    在React中使用Redux数据流
    开发中经常遇到的一些css样式问题
    记录一下CSS outline-width 属性
    使用git stash命令保存和恢复进度
    一分钟搭建好webpack通用坏境
    二维码生成(QRCode.js)
    IE6浏览器有哪些常见的bug,缺陷或者与标准不一致的地方,如何解决
    如何进行网站性能优化
    JavaScript深拷贝与浅拷贝的理解
    新问题: 两个样式对同一个元素操作,为什么最新的样式没有起作用?(已解决)
  • 原文地址:https://www.cnblogs.com/enych/p/11770384.html
Copyright © 2011-2022 走看看