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

    //格式化日期
    function formatDate(d){
        var date1=new Date(d);
        var CurrentDate = "";
       //初始化时间
        var Year= date1.getFullYear();//ie火狐下都可以
        var Month= date1.getMonth()+1;
        var Day = date1.getDate();
        var Hours = date1.getHours();
        var Minutes = date1.getMinutes();
        var Seconds = date1.getSeconds();
        CurrentDate += Year + "年";
        Month >= 10 ? (CurrentDate += Month + "月"):(CurrentDate += "0" + Month + "月");
        Day >= 10 ? (CurrentDate += Day +"日 "):(CurrentDate += "0" + Day+"日 ");
        Hours>=10 ? (CurrentDate += Hours +":"):(CurrentDate += "0"+Hours +":");
        Minutes>=10 ? (CurrentDate += Minutes +":"):(CurrentDate += "0"+Minutes +":");
        Seconds>=10 ? (CurrentDate += Seconds):(CurrentDate += "0"+Seconds);
        return CurrentDate;
    }
    

      

    作者:freddyhuang
    出处:https://www.cnblogs.com/freddyhuang
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

  • 相关阅读:
    My first blog!
    Elasticsearch安装 + Head插件安装 + Bigdesk插件安装
    泛型-反射-注解
    JFinal自定义FreeMarker标签
    Hadoop集群中节点角色定义
    HBase
    MapReduce
    HDFS
    Hadoop基本概念
    HTTP浅析
  • 原文地址:https://www.cnblogs.com/freddyhuang/p/7391006.html
Copyright © 2011-2022 走看看