zoukankan      html  css  js  c++  java
  • js 中格式化显示时间

    function getMyDateTime(str){
    var oDate = new Date(str),
    oYear = oDate.getFullYear(),
    oMonth = oDate.getMonth()+1< 10 ? "0" + (oDate.getMonth()+1) : (oDate.getMonth()+1);
    oDay = oDate.getDate()< 10 ? "0" + oDate.getDate() : oDate.getDate();
    oHour = oDate.getHours() < 10 ? "0" + oDate.getHours() : oDate.getHours();
    oMinute = oDate.getMinutes() < 10 ? "0" + oDate.getMinutes() : oDate.getMinutes();
    oSecond = oDate.getSeconds() < 10 ? "0" + oDate.getSeconds() : oDate.getSeconds();

    oTime = oYear +'-'+ oMonth +'-'+ oDay +" "+ oHour + ":" + oMinute + ":" +oSecond;//最后拼接时间
    return oTime;
    };

  • 相关阅读:
    String类
    Scanner类
    Object类
    接口
    static关键字
    final关键字
    抽象类
    权限修饰符
    方法重写 (Override)
    面向对象思想特征
  • 原文地址:https://www.cnblogs.com/littleapple/p/10790632.html
Copyright © 2011-2022 走看看