• js获取本月起止日期和结束日期


     Datestartstop(){
                function getMonth(type, months) {
                    var d = new Date();
                    var year = d.getFullYear();
                    var month = d.getMonth() + 1;
                    if (Math.abs(months) > 12) {
                        months = months % 12;
                    };
                    if (months != 0) {
                        if (month + months > 12) {
                            year++;
                            month = (month + months) % 12;
                        } else if (month + months < 1) {
                            year--;
                            month = 12 + month + months;
                        } else {
                            month = month + months;
                        };
                    };
                    month = month < 10 ? "0" + month: month;
                    var date = d.getDate();
                    var firstday = year + "-" + month + "-" + "01";
                    var lastday = "";
                    if (month == "01" || month == "03" || month == "05" || month == "07" || month == "08" || month == "10" || month == "12") {
                        lastday = year + "-" + month + "-" + 31;
                    } else if (month == "02") {
                        if ((year % 4 == 0 && year % 100 != 0) || (year % 100 == 0 && year % 400 == 0)) {
                            lastday = year + "-" + month + "-" + 29;
                        } else {
                            lastday = year + "-" + month + "-" + 28;
                        };
                    } else {
                        lastday = year + "-" + month + "-" + 30;
                    };
                    var day = "";
                    if (type == "s") {
                        day = firstday;
                    } else {
                        day = lastday;
                    };
                    return day;
                };
                return [getMonth("s",0),getMonth("e",0)]
            },
    

      

  • 相关阅读:
    HTML 网页创建
    CSS3 opacity
    两数相加的和
    九九乘法表
    Linux下的Makefile初入
    linux 下定义寄存器宏 实现类似于STM32的寄存器操作
    Linux 编译与交叉编译
    linux IMX6 汇编点亮一个LED灯
    Linux基本指令与作用
    C# Task 源代码阅读(2)
  • 原文地址:https://www.cnblogs.com/ffyun/p/14465020.html
Copyright © 2020-2023  润新知