How to get current date without time?

前端 未结 2 744
轻奢々
轻奢々 2021-01-07 23:05

I\'m trying to get the current date without the time and store it in a variable, within JavaScript. It needs to be without time as I\'m converting it to an epoch date, with

2条回答
  •  暖寄归人
    2021-01-07 23:39

    Try this:

    var nowDate = new Date(); 
    var date = nowDate.getFullYear()+'/'+(nowDate.getMonth()+1)+'/'+nowDate.getDate(); 
    

    Note: Adjust format as you want, like reorder day, month, year, remove '/' and get combined date etc.

提交回复
热议问题