14 languages · 84 verified snippets · open reference
Time & Timestamp Code by Programming Language
Copy-paste-ready code for getting the current Unix timestamp, converting between timestamps and dates, and working with ISO 8601 — in every mainstream language, with gotchas documented and outputs verified.
Quick Reference — Top 10 Languages
All Languages
- JavaScript6 examples · precision ms
- Python6 examples · precision μs
- Java6 examples · precision ms
- Go6 examples · precision ns
- PHP6 examples · precision s
- Ruby6 examples · precision μs
- C#6 examples · precision ms
- Rust6 examples · precision ns
- Bash6 examples · precision s
- Kotlin6 examples · precision ms
- Swift6 examples · precision ns
- C++6 examples · precision ns
- C6 examples · precision s
- Perl6 examples · precision s
Copy-Paste Snippets
JavaScript: timestamp to ISO 8601
new Date(1790000000 * 1000).toISOString()Python: timestamp to UTC datetime
from datetime import datetime, timezone
datetime.fromtimestamp(1790000000, tz=timezone.utc)Bash (GNU date): timestamp to date
date -u -d @1790000000PostgreSQL: timestamp to date
SELECT to_timestamp(1790000000);Developer Tools
- JSON to TypeScriptConvert JSON strings to TypeScript interfaces.
- Diff CheckerCompare text or code line by line.
- JSON Formatter & ValidatorFormat, validate, minify, and sort JSON keys in your browser.
- Base64 Encode / DecodeEncode and decode Base64 with UTF-8 Unicode and URL-safe support.
- JWT DecoderDecode and inspect JSON Web Tokens (JWT) header and payload locally.
- UUID GeneratorGenerate cryptographically secure UUID v4 and v7 identifiers in bulk.
- Hash GeneratorGenerate SHA-256, SHA-512, SHA-1, and MD5 hashes for text and files.
- Gigantic JSON ViewerParse and view gigantic JSON files locally.
- Unix Timestamp ConverterTurn a Unix timestamp into UTC, local time and ISO 8601.
Guides
- What Is Unix Time?A plain-language explanation of Unix time, the epoch and why programs count time this way.4 min read
- Seconds vs Milliseconds TimestampsHow to recognise the unit of a timestamp, which platforms use which, and how to convert safely.4 min read
- ISO 8601 Date and Time FormatHow ISO 8601 strings are built, what Z and offsets mean, and the parsing traps that cause off-by-hours bugs.5 min read
- Time Zones and DST for DevelopersThe handful of rules that prevent most time zone bugs, with the daylight saving edge cases explained.5 min read
- The Year 2038 ProblemWhy 32-bit Unix timestamps run out in 2038, what breaks, and how to check your own systems.3 min read
Why Use Castov?
Free
Every tool is free to use, with no usage limits and no paid tier.
Fast
Small pages and almost no JavaScript, so results appear the moment you press Convert.
Private
The converters run in your browser, so what you type stays on your device. The few tools that use our servers, such as Env Vault, say so on their page.
Frequently Asked Questions
Is Castov really free?
Is my data sent to a server?
What is a Unix timestamp?
Should I use seconds or milliseconds?
Which time zones are supported?
Converting timestamps in code?
Pick your language above, or use the Unix Timestamp Converter to verify outputs before you ship.