zoukankan      html  css  js  c++  java
  • js获取指定yyyy-mm格式的时间

    1.获取当月时间格式: yyyy-MM

    getNowFormatDate() {//获取当月时间 yyyy-MM
                var date = new Date();
                var year = date.getFullYear();
                var month = date.getMonth() + 1;
                if (month >= 1 && month <= 9) {
                    month = '0' + month;
                }
                var currentdate = year + '-' + month
                return currentdate;
                //   console.log(currentdate) ;
    }
    View Code

    2.获取当月时间格式: yyyy-MM-dd

    function getNowFormatDate() {  //获取当月时间 yyyy-MM-dd
        var date = new Date();
        var year = date.getFullYear();
        var month = date.getMonth() + 1;
        var strDate = date.getDate();
        if (month >= 1 && month <= 9) {
          month = '0' + month;
        }
        if (strDate >= 1 && strDate <= 9) {
          strDate = '0' + strDate ;
        }
        var currentdate = year + '-' + month + '-' + strDate
        return currentdate;
        // console.log(currentdate);
      }
    View Code

    -------------------------------------------

    个性签名:独学而无友,则孤陋而寡闻。做一个灵魂有趣的人!

    如果觉得这篇文章对你有小小的帮助的话,记得在右下角点个“推荐”哦,博主在此感谢!

    万水千山总是情,打赏一分行不行,所以如果你心情还比较高兴,也是可以扫码打赏博主,哈哈哈(っ•̀ω•́)っ✎⁾⁾!

  • 相关阅读:
    常见 PL.SQL 数据库操作
    PL/SQL常见设置--Kevin的专栏
    pl/sql编程
    添加List集合覆盖问题
    程序猿感情生活的那些事
    表达式树-理解与进阶
    白话神经网络
    EF Core 数据验证
    c#8内插逐字字符串增强功能
    我的新博客
  • 原文地址:https://www.cnblogs.com/mahmud/p/11523413.html
Copyright © 2011-2022 走看看