@iap Packages
    Preparing search index...

    Function formatTimestampToDate

    • 将 Unix 时间戳(秒或毫秒)格式化为日期字符串 根据数字位数自动判断是秒级还是毫秒级时间戳

      Parameters

      • timestamp: string | number

        Unix 时间戳,支持数字或数字字符串;13 位视为毫秒,其他视为秒

      • showTime: boolean = false

        为 true 时附加 HH:mm:ss,默认 false

      Returns string

      格式为 'MM/dd/yyyy'(或含时间)的字符串;无效输入返回 '-'

      formatTimestampToDate(1705276800)           // '01/15/2024'
      formatTimestampToDate(1705276800000, true) // '01/15/2024 00:00:00'