[Javascript] Relative time foramt

  const rtf = new Intl.RelativeTimeFormat(
    navigator.language
  )

  const res = rtf.format(-2, 'day')
  console.log(res) // "2 days ago" 

 

posted @ 2023-03-16 15:31  Zhentiw  阅读(10)  评论(0编辑  收藏  举报