Skip to content

将公历年份转化为农历对应的生肖年

Robert Yao edited this page Jul 2, 2019 · 1 revision
/**
 * 将公历年份转化为农历对应的生肖年
 * ========================================================================
 * @param {String|Number} time - 表示时间的字符串或者数值
 * @returns {string}
 */
const getLunarZodiac = (time) => {
  const ZODIAC = [
    '',
    '',
    '',
    '',
    '',
    '',
    '',
    '',
    '',
    '',
    '',
    ''
  ]
  let diff = new Date(time).getFullYear() - 1864

  return ZODIAC[diff % 12]
}
You can’t perform that action at this time.