Skip to content

formatTime ​

Category
Last Changed
2025-03-21

Automatically update the time ago string when the time changes.

formatter:

  • year: yyyy
  • quarter: q
  • month: MM
  • day: dd
  • hour: hh
  • minute: mm
  • second: ss
  • millisecond: S

Demo ​

parseTime: 2026-08-11 18:01:56
formatTime: 刚刚
0ms
format:
format:

Usage ​

js
import { formatTime, parseTime } from 'comuse-shared'

const timeAgo = formatTime(new Date(2024, 12, 1))

parseTime(new Date(), 'yyyy-MM-dd hh:mm:ss')

Source ​

Source • Demo • Docs

Changelog ​

No recent changes

Released under the MIT License.