zoukankan      html  css  js  c++  java
  • 日期格式化函数

    function timestampToTime(val,to) {
        var val = new Date(val)
        var year = val.getFullYear();
        var month = (val.getMonth()+1 < 10 ? '0'+(val.getMonth()+1) : val.getMonth()+1);
        var date = (val.getDate() < 10 ? '0'+(val.getDate()) : val.getDate());
        var hour = (val.getHours() < 10 ? '0'+(val.getHours()) : val.getHours());
        var minute = (val.getMinutes() < 10 ? '0'+(val.getMinutes()) : val.getMinutes());
        var second = (val.getSeconds() < 10 ? '0'+(val.getSeconds()) : val.getSeconds());
        switch (to){
            case 'day':
                return year+'-'+month+'-'+date;
                break;
            case 'second':
                return year+'-'+month+'-'+date+' '+hour+':'+minute+':'+second;
                break;
        }
    }

    日期格式化函数。不够补零。

  • 相关阅读:
    洛谷P2050 美食节
    洛谷P2150 寿司晚宴
    区间最深LCA
    三层交换机
    VLAN 及 GVRP 配置
    GVRP
    VLAN IEEE802.1Q
    以太网端口技术
    网关与路由器
    Quidway S系列交换机
  • 原文地址:https://www.cnblogs.com/helloNico/p/10194667.html
Copyright © 2011-2022 走看看