How to get current date in jquery?

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

    //convert month to 2 digits

    var twoDigitMonth = ((fullDate.getMonth().length+1) === 1)? (fullDate.getMonth()+1) : '0' + (fullDate.getMonth()+1); var currentDate = fullDate.getFullYear()+ "/" + twoDigitMonth + "/" + fullDate.getDate(); console.log(currentDate);
    //2011/05/19

提交回复
热议问题