schangxiang@126.com
2025-09-10 3d43ffa3152110b7823f9fa6320c08a6ae02358a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/**
 *  @description 获取年月日  时分秒
 *  @returns {string}  yyyy-MM-dd hh:mm:ss
 */
export function getDate(option) {
  if(option==null) return '';//如果为null,则返回空 【EditBy shaocx,2022-09-16】
  const date = new Date(option);
  let str = date.getFullYear() + '-' + addZero(date.getMonth() + 1) + '-' + addZero(date.getDate());
 
  // if (option && option.full) {
  str += ' ' + addZero(date.getHours()) + ':' + addZero(date.getMinutes()) + ':' + addZero(date.getSeconds());
  // }
  return str;
}
const addZero = function (date) {
  return date > 9 ? date : '0' + date;
};