我给这个对象获得日期的最小值和最大值的对象
{"2017-1-1":true,"2017-1-2":true,"2017-1-3":true}
,我怎样才能得到最小日期和最大日期?我也需要范围。我做的是
temp = Object.keys(obj[0]).split('-')[2]
const minDate = Math.min(...temp);
const maxDate = Math.min(...temp);
//and then concat year and month to rebuild the date format
我认为这是不好的代码。任何更好的选择?
如果以“”yyyy-mm-dd“'格式保存日期,生活会容易得多。 – 2017-03-18 06:06:39
什么是'obj'?你期望'obj [0]'是什么? – 2017-03-18 06:07:50