Skip to content

formatTime

Category
Last Changed
3月21日8时25分

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: 2025-06-27 09:22:58
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

SourceDemoDocs

Changelog

v3.2.7 on 3/25/2025
a32db - feat: add nowStr function
v3.1.3 on 1/17/2025
da716 - feat: add test and demo for parseTime function
v3.1.2 on 1/9/2025
d3741 - feat: parseTime

Released under the MIT License.