zoukankan      html  css  js  c++  java
  • 获取当前日期, 当前年月,时间戳转换年月日,时间戳转换年月日时秒,时间戳转换年月日时分秒。

    // 获取当前日期
    function getLocalDate() {
        var times = getYMDHMS(new Date());
        return times.year + "-" + times.month + "-" + times.date;
    }
    
    // 获取当前年月
    function getLocalYearMonth() {
        var times = getYMDHMS(new Date());
        return times.year + "-" + times.month;
    }
    // 根据传的日期获取
    function getLocalDateTime(time) {
        var times = getYMDHMS(time);
        return times.year + "-" + times.month + "-" + times.date;
    }
    
    // 时间戳转换年月日
    function getAppointTime(time) {
        var timett = time * 1000;
    
        var times = getYMDHMS(new Date(timett));
        return times.year + "-" + times.month + "-" + times.date;
    }
    
    // 时间戳转换年月日时秒
    function getAppointTimeSec(time) {
        var timett = time * 1000;
    
        var times = getYMDHMS(new Date(timett));
        return times.year + "-" + times.month + "-" + times.date + " " + times.hours + ":" + times.minute + ":" + times.second;
    }
    
    // 时间戳转换年月日时分秒
    function getAppointTimePro(time) {
        var timett = time * 1000;
        var times = getYMDHMS(new Date(timett));
        return times.year + "-" + times.month + "-" + times.date + " " + times.hours + ":" + times.minute + ':' + times.second;
    }
    

     

    //这种格式:2018-12-26 16:35:56
    function
    changeDateFormat (time) { var myDate = new Date(time); var day=myDate.getDate(); if (day<10)day="0"+day; var YMD=myDate.getFullYear() + "-" + (myDate.getMonth()+1) + "-" + day; var HMS=myDate.getHours() + ":" + myDate.getMinutes() + ":" + myDate.getSeconds(); var YMDHMS=YMD+" "+HMS; return     YMDHMS; }
  • 相关阅读:
    多线程与Socket编程
    正则表达式
    委托事件泛型
    C#基础加强
    随笔
    不设置JAVA_HOME运行eclipse
    CentOS7.x系统中使用Docker时,在存储方面需要注意的问题
    【转】关于高可用负载均衡的探索-基于Rancher和Traefic
    Rancher 容器管理平台-免费视频培训-链接及内容-第三季
    使用Rancher的RKE快速部署Kubernetes集群
  • 原文地址:https://www.cnblogs.com/yangsg/p/10149538.html
Copyright © 2011-2022 走看看