Timestamp Toolkit
A simple timestamp conversion and formatting tool.
Features
- - Timestamp to DateTime - Convert Unix timestamp to readable datetime
- DateTime to Timestamp - Convert datetime string to Unix timestamp
- Format Conversion - Convert between various date formats
- Current Time - Get current timestamp in multiple formats
- Relative Time - Calculate time differences
Usage
CODEBLOCK0
Actions
| Action | Description |
|---|
| INLINECODE0 | Get current timestamp |
| INLINECODE1 |
Convert timestamp to datetime |
|
to-timestamp | Convert datetime to timestamp |
|
format | Format datetime string |
|
diff | Calculate time difference |
Options
| Option | Type | Default | Description |
|---|
| INLINECODE5 | string | - | Input timestamp or datetime |
| INLINECODE6 |
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) |
Examples
CODEBLOCK1
Supported Formats
| 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 |
Use Cases
- 1. Log Analysis - Convert timestamps in logs to readable format
- API Development - Handle timestamp conversions
- Data Processing - Normalize time formats
- Debugging - Quick timestamp conversions
Current Status
In development.
时间戳工具包
一个简单的时间戳转换和格式化工具。
功能特性
- - 时间戳转日期时间 - 将Unix时间戳转换为可读的日期时间
- 日期时间转时间戳 - 将日期时间字符串转换为Unix时间戳
- 格式转换 - 在各种日期格式之间进行转换
- 当前时间 - 以多种格式获取当前时间戳
- 相对时间 - 计算时间差
使用方法
bash
python3 skills/timestamp-toolkit/scripts/timestamp.py <操作> [选项]
操作指令
| 操作指令 | 描述 |
|---|
| now | 获取当前时间戳 |
| to-datetime |
将时间戳转换为日期时间 |
| to-timestamp | 将日期时间转换为时间戳 |
| format | 格式化日期时间字符串 |
| diff | 计算时间差 |
选项参数
| 选项 | 类型 | 默认值 | 描述 |
|---|
| --input | 字符串 | - | 输入的时间戳或日期时间 |
| --format |
字符串 | %Y-%m-%d %H:%M:%S | 输出格式 |
| --tz | 字符串 | local | 时区(local、utc或时区名称) |
| --unit | 字符串 | s | 时间戳单位(s=秒,ms=毫秒) |
使用示例
bash
获取当前时间戳
python3 skills/timestamp-toolkit/scripts/timestamp.py now
将时间戳转换为日期时间
python3 skills/timestamp-toolkit/scripts/timestamp.py to-datetime --input 1700000000
将日期时间转换为时间戳
python3 skills/timestamp-toolkit/scripts/timestamp.py to-timestamp --input 2024-03-22 14:00:00
格式化日期时间
python3 skills/timestamp-toolkit/scripts/timestamp.py format --input 2024-03-22 --format %Y年%m月%d日
计算时间差
python3 skills/timestamp-toolkit/scripts/timestamp.py diff --input 2024-01-01 --input2 2024-03-22
支持的格式
| 格式 | 示例 |
|---|
| ISO 8601 | 2024-03-22T14:00:00Z |
| 标准格式 |
2024-03-22 14:00:00 |
| 中文格式 | 2024年3月22日 14:00:00 |
| 自定义格式 | 任意Python strftime格式 |
应用场景
- 1. 日志分析 - 将日志中的时间戳转换为可读格式
- API开发 - 处理时间戳转换
- 数据处理 - 规范化时间格式
- 调试排错 - 快速进行时间戳转换
当前状态
开发中