• xiaota-format


    function add0(m){return m<10?'0'+m:m }
    var format = {
        Y:function(shijianchuo){
            if(!shijianchuo){
                return;
            }
            var time = new Date(shijianchuo);
            var y = time.getFullYear();
            var m = time.getMonth()+1;
            var d = time.getDate();
            return y+'-'+add0(m)+'-'+add0(d);
        },
        M:function(shijianchuo){
            if(!shijianchuo){
                return;
            }
            var time = new Date(shijianchuo);
            var y = time.getFullYear();
            var m = time.getMonth()+1;
            var d = time.getDate();
            var h = time.getHours();
            var min = time.getMinutes();
            return y+'-'+add0(m)+'-'+add0(d)+' '+add0(h)+':'+add0(min);
        },
        Min:function(shijianchuo){
            if(!shijianchuo){
                return;
            }
            var time = new Date(shijianchuo);
            var h = time.getHours();
            var min = time.getMinutes();
            return add0(h)+':'+add0(min);
        },
    }
    export default format;
  • 相关阅读:
    281. Zigzag Iterator
    298. Binary Tree Longest Consecutive Sequence
    482. License Key Formatting
    361. Bomb Enemy
    373. Find K Pairs with Smallest Sums
    304. Range Sum Query 2D
    308. Range Sum Query 2D
    307. Range Sum Query
    303. Range Sum Query
    247. Segment Tree Query II
  • 原文地址:https://www.cnblogs.com/xiaoxiao95/p/12726378.html
Copyright © 2020-2023  润新知