Javascript Date - set just the date, ignoring time?

后端 未结 4 686
梦毁少年i
梦毁少年i 2021-02-06 23:58

I have a bunch of objects, each of which has a timestamp, that I want to group by date, into a JSON object. The ultimate goal is something like this:

myObject =          


        
4条回答
  •  轮回少年
    2021-02-07 00:07

    var today = new Date();
    var year = today.getFullYear();
    var mes = today.getMonth()+1;
    var dia = today.getDate();
    var fecha =dia+"-"+mes+"-"+year;
    console.log(fecha);

提交回复
热议问题