Skip to main content
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 @1790000000

PostgreSQL: timestamp to date

SELECT to_timestamp(1790000000);

Developer Tools

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?
Yes. All tools are free, with no account and no usage limits. The site may show ads in the future to cover running costs.
Is my data sent to a server?
Time, date and converter tools do not upload your input to Castov servers. Some preferences, such as theme, custom time zones and selected models, are stored locally on your device. Some features use the network by design: Env Vault uploads an encrypted copy, and P2P tools use public signaling servers.
What is a Unix timestamp?
A Unix timestamp is the number of seconds since 1 January 1970 at 00:00:00 UTC. It identifies one moment in time regardless of time zone, which is why programs and APIs use it.
Should I use seconds or milliseconds?
Use whichever your system produces. A 10-digit value is in seconds and a 13-digit value is in milliseconds. The converters can detect the unit for you.
Which time zones are supported?
All IANA time zones supported by your browser, such as America/New_York, Europe/Paris, Africa/Algiers and Asia/Tokyo, with daylight saving time rules applied for the date you choose.

Converting timestamps in code?

Pick your language above, or use the Unix Timestamp Converter to verify outputs before you ship.