zoukankan      html  css  js  c++  java
  • js--------js获取当前时间,返回日期yyyy-MM-dd

     1 //获取当前时间 yyyy-MM-dd
     2 function getNowFormatDate() {
     3     var date = new Date();
     4     var seperator1 = "-";
     5     var seperator2 = ":";
     6     var month = date.getMonth() + 1;
     7     var strDate = date.getDate();
     8     if (month >= 1 && month <= 9) {
     9         month = "0" + month;
    10     }
    11     if (strDate >= 0 && strDate <= 9) {
    12         strDate = "0" + strDate;
    13     }
    14     var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate;
    15     return currentdate;
    16 }
     1 //获取当前日期,个位数用0占位
     2 function getNowWithLine() {
     3     var date = new Date();
     4     var seperator1 = "/";
     5     var seperator2 = ":";
     6     var month = date.getMonth() + 1;
     7     var strDate = date.getDate();
     8     if (month >= 1 && month <= 9) {
     9         month = "0" + month;
    10     }
    11     if (strDate >= 0 && strDate <= 9) {
    12         strDate = "0" + strDate;
    13     }
    14     var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate;
    15     return currentdate;
    16 }
     1 //获取指定日期的前几天日期或后几天日期
     2 function getDateFromCurrentDate(fromDate, dayInterval) {
     3 
     4     var curDate = new Date(Date.parse(fromDate.replace(/-/g, "/")));
     5     curDate.setDate(curDate.getDate() + dayInterval);
     6     var year = curDate.getFullYear();
     7     var month = (curDate.getMonth() + 1) < 10 ? "0" + (curDate.getMonth() + 1) : (curDate.getMonth() + 1);
     8     var day = curDate.getDate() < 10 ? "0" + curDate.getDate() : curDate.getDate();
     9     return year + "-" + month + "-" + day;
    10 };
     1 //当前日期加n天 返回日期 yyyy-MM-dd
     2 function getFormatDate(addDay) {
     3     var date = new Date();
     4     date.setDate(date.getDate() + addDay);
     5     var seperator1 = "-";
     6     var month = date.getMonth() + 1;
     7     var strDate = date.getDate();
     8     if (month >= 1 && month <= 9) {
     9         month = "0" + month;
    10     }
    11     if (strDate >= 0 && strDate <= 9) {
    12         strDate = "0" + strDate;
    13     }
    14     var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate;
    15     return currentdate;
    16 }
  • 相关阅读:
    Microsoft 补丁,文档下载
    web_dynpro_Tree1:
    右键的CONTEXT_MENU
    web_dynpro_ALV:(包ZLYTEST2)(alv 的事件只需注意一个R_PARAM就哦了)
    web_dynpro_SELECT_OPTION组件的使用:
    首日签到
    斐波那契数列
    C#正则表达式验证工具
    P210阶段3(个人所得税计算器)
    javascript基本语法
  • 原文地址:https://www.cnblogs.com/chocolatexll/p/9274853.html
Copyright © 2011-2022 走看看