timestamp

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Timestamp Skill

Timestamp 工具

Convert between various timestamp formats.
在多种时间戳格式之间进行转换。

When to Use

适用场景

USE this skill when:
  • "Convert this timestamp to readable date"
  • "What time is 1704067200?"
  • "Get current timestamp"
  • "Parse this date string"
  • "Calculate time difference"
使用本工具的场景:
  • "将此时间戳转换为可读日期"
  • "1704067200对应的时间是什么?"
  • "获取当前时间戳"
  • "解析此日期字符串"
  • "计算时间差"

When NOT to Use

不适用场景

DON'T use this skill when:
  • Scheduling tasks → use cron/system scheduler
  • Time zone conversions → use timezone-aware libraries
  • Calendar operations → use calendar tools
请勿使用本工具的场景:
  • 任务调度 → 使用cron/系统调度器
  • 时区转换 → 使用支持时区的库
  • 日历操作 → 使用日历工具

Commands

命令说明

Current Time

获取当前时间

bash
{baseDir}/timestamp.sh now
{baseDir}/timestamp.sh now --format iso
{baseDir}/timestamp.sh now --format unix
{baseDir}/timestamp.sh now --utc
bash
{baseDir}/timestamp.sh now
{baseDir}/timestamp.sh now --format iso
{baseDir}/timestamp.sh now --format unix
{baseDir}/timestamp.sh now --utc

Convert Timestamp

转换时间戳

bash
{baseDir}/timestamp.sh convert 1704067200
{baseDir}/timestamp.sh convert "2024-01-01T00:00:00Z"
{baseDir}/timestamp.sh convert "January 1, 2024"
{baseDir}/timestamp.sh convert 1704067200 --format iso
bash
{baseDir}/timestamp.sh convert 1704067200
{baseDir}/timestamp.sh convert "2024-01-01T00:00:00Z"
{baseDir}/timestamp.sh convert "January 1, 2024"
{baseDir}/timestamp.sh convert 1704067200 --format iso

Relative Time

相对时间计算

bash
{baseDir}/timestamp.sh relative "2 hours ago"
{baseDir}/timestamp.sh relative "tomorrow"
{baseDir}/timestamp.sh relative "next week"
{baseDir}/timestamp.sh relative "in 3 days"
bash
{baseDir}/timestamp.sh relative "2 hours ago"
{baseDir}/timestamp.sh relative "tomorrow"
{baseDir}/timestamp.sh relative "next week"
{baseDir}/timestamp.sh relative "in 3 days"

Time Difference

时间差计算

bash
{baseDir}/timestamp.sh diff "2024-01-01" "2024-01-10"
{baseDir}/timestamp.sh diff 1704067200 1704153600
{baseDir}/timestamp.sh diff "now" "tomorrow"
bash
{baseDir}/timestamp.sh diff "2024-01-01" "2024-01-10"
{baseDir}/timestamp.sh diff 1704067200 1704153600
{baseDir}/timestamp.sh diff "now" "tomorrow"

Parse Date String

解析日期字符串

bash
{baseDir}/timestamp.sh parse "January 1, 2024"
{baseDir}/timestamp.sh parse "2024-01-01 12:00:00"
{baseDir}/timestamp.sh parse "01/01/2024"
bash
{baseDir}/timestamp.sh parse "January 1, 2024"
{baseDir}/timestamp.sh parse "2024-01-01 12:00:00"
{baseDir}/timestamp.sh parse "01/01/2024"

Output Formats

输出格式

FormatDescriptionExample
unix
Unix timestamp
1704067200
iso
ISO 8601
2024-01-01T00:00:00Z
date
Date only
2024-01-01
time
Time only
00:00:00
datetime
Date and time
2024-01-01 00:00:00
human
Human readable
Monday, January 1, 2024
relative
Relative time
2 hours ago
格式说明示例
unix
Unix时间戳
1704067200
iso
ISO 8601格式
2024-01-01T00:00:00Z
date
仅日期
2024-01-01
time
仅时间
00:00:00
datetime
日期和时间
2024-01-01 00:00:00
human
人类可读格式
Monday, January 1, 2024
relative
相对时间
2 hours ago

Examples

示例

Get current Unix timestamp:
bash
{baseDir}/timestamp.sh now --format unix
获取当前Unix时间戳:
bash
{baseDir}/timestamp.sh now --format unix

Output: 1704067200

输出: 1704067200


**Convert Unix to ISO:**
```bash
{baseDir}/timestamp.sh convert 1704067200 --format iso

**将Unix时间戳转换为ISO格式:**
```bash
{baseDir}/timestamp.sh convert 1704067200 --format iso

Output: 2024-01-01T00:00:00Z

输出: 2024-01-01T00:00:00Z


**Get time 2 hours from now:**
```bash
{baseDir}/timestamp.sh relative "in 2 hours"

**获取2小时后的时间:**
```bash
{baseDir}/timestamp.sh relative "in 2 hours"

Output: 2024-01-01T02:00:00Z

输出: 2024-01-01T02:00:00Z


**Calculate days between dates:**
```bash
{baseDir}/timestamp.sh diff "2024-01-01" "2024-01-31" --unit days

**计算两个日期之间的天数:**
```bash
{baseDir}/timestamp.sh diff "2024-01-01" "2024-01-31" --unit days

Output: 30 days

输出: 30 days

undefined
undefined

Notes

注意事项

  • All operations use UTC by default
  • Use
    --local
    for local timezone
  • Supports various date formats
  • Handles relative time expressions
  • 所有操作默认使用UTC时区
  • 使用
    --local
    参数切换为本地时区
  • 支持多种日期格式
  • 支持处理相对时间表达式