How to get current date in jquery?

前端 未结 30 1908
春和景丽
春和景丽 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:12

    function createDate() {
                var date    = new Date(),
                    yr      = date.getFullYear(),
                    month   = date.getMonth()+1,
                    day     = date.getDate(),
                    todayDate = yr + '-' + month + '-' + day;
                console.log("Today date is :" + todayDate);
    

提交回复
热议问题