function fixZero(params: number) {
  if (params < 10) {
    return '0' + params;
  }
  return params;
}

export function formatTime(time: number) {
  const now: Date = new Date(time * 1000);
  const year = now.getFullYear();
  const month = now.getMonth() + 1;
  const date = now.getDate();
  const hour = now.getHours();
  const minute = now.getMinutes();
  const second = now.getSeconds();
  return (
    year +
    '-' +
    fixZero(month) +
    '-' +
    fixZero(date) +
    ' ' +
    fixZero(hour) +
    ':' +
    fixZero(minute) +
    ':' +
    fixZero(second)
  );
}
