A simple timestamp conversion and formatting tool.
python3 skills/timestamp-toolkit/scripts/timestamp.py <action> [options]
| Action | Description |
|---|---|
| -------- | ------------- |
now | Get current timestamp |
to-datetime | Convert timestamp to datetime |
to-timestamp | Convert datetime to timestamp |
format | Format datetime string |
diff | Calculate time difference |
| Option | Type | Default | Description |
|---|---|---|---|
| -------- | ------ | --------- | ------------- |
--input | string | - | Input timestamp or datetime |
--format | string | %Y-%m-%d %H:%M:%S | Output format |
--tz | string | local | Timezone (local, utc, or timezone name) |
--unit | string | s | Timestamp unit (s=seconds, ms=milliseconds) |
# Get current timestamp
python3 skills/timestamp-toolkit/scripts/timestamp.py now
# Convert timestamp to datetime
python3 skills/timestamp-toolkit/scripts/timestamp.py to-datetime --input 1700000000
# Convert datetime to timestamp
python3 skills/timestamp-toolkit/scripts/timestamp.py to-timestamp --input "2024-03-22 14:00:00"
# Format datetime
python3 skills/timestamp-toolkit/scripts/timestamp.py format --input "2024-03-22" --format "%Y年%m月%d日"
# Calculate time difference
python3 skills/timestamp-toolkit/scripts/timestamp.py diff --input "2024-01-01" --input2 "2024-03-22"
| Format | Example |
|---|---|
| -------- | --------- |
| ISO 8601 | 2024-03-22T14:00:00Z |
| Standard | 2024-03-22 14:00:00 |
| Chinese | 2024年3月22日 14:00:00 |
| Custom | Any Python strftime format |
In development.
共 1 个版本