Python Timestamp Converter
Paste the following prompt into your AI chat to install this skill:
Install @user_15292d5a/yjkj-cn-timestamp-tool according to https://skillhub.cn/install/skillhub.md.
About this skill
Problem
Engineers often need to move between Unix timestamps and readable dates: a log value like 1720000000 must be interpreted, while an API date such as 2024-07-01 12:00:00 may need to become a timestamp. Hand-written datetime code can easily introduce timezone, second/millisecond, or formatting mistakes.
How It Works
cn-timestamp-tool wraps common conversions with the Python standard library, without external dependencies or an API key. Its core capabilities are:
- Timestamp to date-time: render Unix timestamps as readable times for logs and API responses
- Date-time to timestamp: convert human-readable dates to int timestamps for queries or storage fields
- Current timestamp: return the current Unix timestamp in seconds or milliseconds
- Timezone support: use zoneinfo for different zones, defaulting to Asia/Shanghai
A typical flow parses the input, selects the timezone, uses datetime and time to format or normalize the value, then outputs the requested type. argparse provides a command-line entry point for scripts and quick debugging.
Boundaries
It covers common local timestamp conversion, not full timezone arithmetic, NTP synchronization, or business calendar logic. Check whether date strings carry timezone information, and do not mix second- and millisecond-based fields. If the project needs cross-timezone reporting or DST-sensitive auditing, validate results against explicit business rules.
Use Cases
- Convert Unix timestamp 1720000000 to Asia/Shanghai time.
- Convert 2024-07-01 12:00:00 to a seconds timestamp.
- Get current seconds or milliseconds timestamp for test data.
- Convert date time to timestamp for Asia/Shanghai or zones.
Best For
- Backend engineer: reads Unix timestamps in logs as local time.
- API engineer: converts dates to second timestamps for queries.
- Test engineer: generates current second/millisecond timestamps for data.
- Script author: normalizes date strings into timestamps in local scripts.
Related Skills
Automatically indexes Gradle-cached AAR/JAR dependency classes and returns library coordinates, versions, and public APIs by fully qualified name, using only the Python standard library.
Codifies AMT and YourMT3 training conventions, script patterns, hyperparameters, precision, checkpoints, and NaN safeguards.
Retrieve relevant chunks from a customer-managed PKM dataset by dataset_id and return concise, source-annotated answers.
Convert PRDs, user stories, or functional specs into prioritized test-point checklists covering functional, business-rule, boundary, exception, and non-functional dimensions.