js根据日期或时间戳获取年月日时分秒 function formatTime(time){ var date = new Date(time); // 初始化日期 var year = date.getFullYear(); //获取年份