Agent skill
timestamp-standard
Frontend-backend time data transmission standard, using millisecond timestamps for time points (timezone-independent); Duration/Period use ISO 8601 string format.
Stars
163
Forks
31
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/development/timestamp-standard
SKILL.md
Time Representation Standard
Time Point (Instant)
| Type | Format | Description |
|---|---|---|
| Time Point | number | Millisecond timestamp, UTC-based, timezone-independent |
Core Principles:
- All time points use millisecond timestamps (Unix Epoch Milliseconds)
- Timestamps are timezone-independent, frontend converts display based on user timezone
- Database storage, API transmission, frontend-backend interaction all use numeric type
Duration
| Type | Format | Example | Description |
|---|---|---|---|
| Duration | string | PT1H30M |
ISO 8601 duration format |
Duration Format: PT[n]H[n]M[n]S
PT1H- 1 hourPT30M- 30 minutesPT1H30M- 1 hour 30 minutesPT45S- 45 secondsPT1H30M45S- 1 hour 30 minutes 45 seconds
Period
| Type | Format | Example | Description |
|---|---|---|---|
| Period | string | P1Y2M3D |
ISO 8601 date period format |
Period Format: P[n]Y[n]M[n]D
P1Y- 1 yearP2M- 2 monthsP3D- 3 daysP1Y2M3D- 1 year 2 months 3 days
Usage Examples
Interface Definition
typescript
interface Event {
createdAt: number // 1732608000000
updatedAt: number // 1732694400000
duration: string // "PT2H30M"
validPeriod: string // "P1Y"
}
Frontend Conversion
typescript
// timestamp to local display
const display = new Date(timestamp).toLocaleString()
// local time to timestamp
const timestamp = new Date().getTime()
Backend Processing (Kotlin/Java)
kotlin
// Instant and timestamp conversion
val instant = Instant.ofEpochMilli(timestamp)
val timestamp = instant.toEpochMilli()
// Duration parsing
val duration = Duration.parse("PT1H30M")
// Period parsing
val period = Period.parse("P1Y2M")
Design Philosophy
- Timestamps: Numeric type for efficient transmission, no timezone ambiguity, cross-language compatible
- Duration/Period: ISO 8601 standard format, clear semantics, native parsing support
Didn't find tool you were looking for?