Function getFriendlyInterval

  • 获取间隔时间

    Usage:

    const ret1 = getFriendlyInterval(new Date('2020-03-28 00:09:27'), new Date('2023-04-18 10:54:00'), { type: 'd' });
    const ret2 = getFriendlyInterval(1585325367000, 1681786440000, { type: 'text' });
    const ret3 = getFriendlyInterval('2020-03-28 00:09:27', '2023-04-18 10:54:00', { type: 'text' });
    console.log(ret1);
    console.log(ret2);
    console.log(ret3);

    Output:

    1116
    1116 天 10 时 44 分 33 秒
    1116 天 10 时 44 分 33 秒
    

    Parameters

    • start: string | number | Date = 0

      开始时间戳 1585325367122

    • end: string | number | Date = 0

      结束时间戳 1585325367122

    • options: {
          type?: string;
      } = defaultGetFriendlyIntervalOptions
      • Optional type?: string

        返回类型 d: 2(天) text: 2 天 4 时...

    Returns number | string

    取决于 type