How to get current date in jquery?

前端 未结 30 1905
春和景丽
春和景丽 2020-11-27 09:51

I want to know how to use the Date() function in jQuery to get the current date in a yyyy/mm/dd format.

30条回答
  •  误落风尘
    2020-11-27 10:16

    function GetTodayDate() {
       var tdate = new Date();
       var dd = tdate.getDate(); //yields day
       var MM = tdate.getMonth(); //yields month
       var yyyy = tdate.getFullYear(); //yields year
       var currentDate= dd + "-" +( MM+1) + "-" + yyyy;
    
       return currentDate;
    }
    

    Very handy function to use it, Enjoy. You do not require any javascript framework. it just works in with plain javascript.

提交回复
热议问题