datetime-tool
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDateTime Tool
DateTime Tool
处理时间和日期相关的操作。
Handle operations related to time and date.
When to Use
When to Use
- 用户询问当前时间或日期
- 需要格式化日期输出
- 计算两个日期之间的差值
- 时区转换
- 获取星期几、月份名称等
- Users ask about current time or date
- Need to format date output
- Calculate the difference between two dates
- Time zone conversion
- Get day of the week, month name, etc.
Instructions
Instructions
获取当前时间
Get Current Time
运行脚本获取当前时间:
bash
python scripts/get_time.py支持的参数:
- : 指定时区 (如 Asia/Shanghai, UTC)
--timezone <tz> - : 日期格式 (如 %Y-%m-%d %H:%M:%S)
--format <fmt>
Run the script to get the current time:
bash
python scripts/get_time.pySupported parameters:
- : Specify time zone (e.g., Asia/Shanghai, UTC)
--timezone <tz> - : Date format (e.g., %Y-%m-%d %H:%M:%S)
--format <fmt>
计算日期差值
Calculate Date Difference
bash
python scripts/get_time.py --diff "2024-01-01" "2024-12-31"bash
python scripts/get_time.py --diff "2024-01-01" "2024-12-31"时区转换
Time Zone Conversion
bash
python scripts/get_time.py --convert "2024-01-01 12:00:00" --from-tz UTC --to-tz Asia/Shanghaibash
python scripts/get_time.py --convert "2024-01-01 12:00:00" --from-tz UTC --to-tz Asia/ShanghaiOutput Format
Output Format
脚本输出 JSON 格式:
json
{
"datetime": "2024-01-15 10:30:00",
"date": "2024-01-15",
"time": "10:30:00",
"timezone": "Asia/Shanghai",
"weekday": "Monday",
"timestamp": 1705285800
}The script outputs in JSON format:
json
{
"datetime": "2024-01-15 10:30:00",
"date": "2024-01-15",
"time": "10:30:00",
"timezone": "Asia/Shanghai",
"weekday": "Monday",
"timestamp": 1705285800
}Common Formats
Common Formats
| 格式 | 示例 |
|---|---|
| ISO | 2024-01-15T10:30:00+08:00 |
| 中文 | 2024年01月15日 10:30:00 |
| 美式 | 01/15/2024 |
| 欧式 | 15/01/2024 |
| Format | Example |
|---|---|
| ISO | 2024-01-15T10:30:00+08:00 |
| Chinese | 2024-01-15 10:30:00 |
| American | 01/15/2024 |
| European | 15/01/2024 |