首页 > 其他分享 >获取月份的最后一天

获取月份的最后一天

时间:2023-11-29 21:33:22浏览次数:35  
标签:Date 月份 一天 month 获取 let year lastMonthday lastDay

new Date(year, month, 0).getDate()

 // 获取月份的最后一天
        let now = new Date()
        let year = now.getFullYear()
        let month = now.getMonth() - 1

        function lastMonthday(year, month) {
            let lastDay = new Date(year, month, 0).getDate()
            console.log(lastDay);
            return lastDay
        }

        lastMonthday(year, month)
        lastMonthday('2023', '10')

标签:Date,月份,一天,month,获取,let,year,lastMonthday,lastDay
From: https://www.cnblogs.com/wszzj/p/17865924.html

相关文章

  • 主线程如何获取子线程异常
    主线程如何获取子线程异常常规情况:一般我们没有办法通过主线程去获取子线程的异常举个例子:publicclasstest11_29{publicstaticvoidmain(String[]args){try{Threadthread=newThread(newmyExceptionRunner());thread.star......
  • Ant-Design modal对话框未打开时,无法通过uesRef获取modal内部元素DOM节点
    为什么要记录下来呢?因为我在网上和chatGpt上没有搜到合适的解决方案。在CDNS上看到个和我遇到问题一样的,居然要收费才能看,所以自己记下来。当然肯定还有其他的好方案,欢迎大家留言。需求:使用antdV/g6画关系图,类似于企查查上面的那样:点击按钮打开Modal框,把数据渲染到Modal框的div......
  • Android 两种方获取U盘的挂载路径
    第一种publicStringgetUsbPath(){try{StorageManagersm=(StorageManager)MyApplication.getContext().getSystemService(STORAGE_SERVICE);MethodgetVolumePathsMethod=StorageManager.class.getMethod("getVolumePaths&qu......
  • 获取Windows内核对象的索引与对象名
    下列提出两种获取对象名的方式通过_OBJECT_TYPE::Name获取对象名称,通过_OBJECT_TYPE::Index获取对象索引;通过NtQueryObject的方式获取,r0与r3通用,代码如下:#include<cstdio>#include<cstdlib>#include<iostream>#include<Windows.h>#defineNT_SUCCESS(Status)((NTST......
  • 获取今天零点的时间戳
    #获取今天零点的时间戳#获取当前时间戳,取余一天的秒数86400,得到今天过了多少秒#用当前的时间戳减去今天过去的秒数,得到今天零点的时间戳#注意要减去time.timezone获取当前时区的时间戳importtimefromdatetimeimportdatetimenow_time=int(time.time())day_time......
  • 代码随想录算法训练营第一天| 704. 二分查找、27. 移除元素
    LeetCode704二分查找题目链接:LeetCode704左闭右闭:视频讲解:手把手带你撕出正确的二分法思路:在循环条件中注明left<=right,即[left,right]classSolution{public:intsearch(vector<int>&nums,inttarget){intleft=0,right=nums.size()-1......
  • .Net Core 单元测试获取配置文件节点值
     单元测试类:ServiceProvider_serviceProvider;IConfiguration_config;[SetUp]publicvoidSetup(){_config=newConfigurationBuilder().Add(newJsonConfigurationSource{Path="appsettings.jso......
  • js和python获取1-100之间的质数
    jsfor(leti=2;i<=100;i++){letiszs=truefor(letj=2;j<i;j++){if(i%j===0){iszs=falsebreak}}if(iszs){zs.push(i)}}console.log(zs)pythonzs=[]foriinrange(2,101):iszs......
  • windows 获取 序列号 wwid方法
     以下任意一条命令都可以:wmicdiskdrivegetserialnumberwmicpathwin32_physicalmediagetSerialNumberwmicpathWin32_DiskDrivegetSerialNumber运行结果: **注意**:windows7下获取的序列号格式可能和Windows10下的不一样获取硬盘的更多信息wmicdis......
  • 使用axios获取接口返回二进制流进行文件下载
    1、当接口返回值类型是'application/json'时,处理报错信息1if(response.data.type&&response.data.type=='application/json'){2letreader=newFileReader();3//处理load事件。该事件在读取操作完成时触发4reader.onload=e=>......