Timeplain

Database Timestamp Converter

Convert timestamps and dates into SQL and MongoDB examples. Copy conversions for MySQL/MariaDB, PostgreSQL, SQLite, SQL Server, and MongoDB.

Enter a timestamp or local date below, then choose your database in “Use this in a database.” Examples update with your input and include both conversion directions, expected UTC values, and copy buttons.

Help & feedback
Convert from

Seconds or milliseconds since January 1, 1970 UTC.

Result

Timezone
—
Offset
—

Other formats

Convert a time to see its formats.

ISO 8601 and RFC 3339 UTC values match for ordinary dates. HTTP dates use whole seconds. RFC 3339 and HTTP dates require a four-digit year.

Show code for your converted time

Your converted time in code

Examples use the resolved instant and destination timezone. JavaScript uses Unix milliseconds; PHP parses an explicit UTC date; Python uses timezone-aware dates. Ruby uses TZInfo for named time zones. Java and C++ start from Unix milliseconds. None rely on your computer’s default timezone.

Convert a time to generate an example.

Repeated local times get two separate examples. These reproduce your resolved conversion; they do not validate arbitrary local-time input. JavaScript display text and timezone rules can vary with runtime locale data. PHP examples support four-digit years. Python requires 3.9+ and supports years 1–9999. If timezone data is missing, install it with python -m pip install tzdata. Ruby requires the TZInfo 2.x gem and timezone data (install tzinfo-data if needed). Ruby examples support years 0000–9999 in UTC and the destination timezone. Java requires 8+. C++ requires a C++20 standard library with chrono timezone support, std::format, and installed IANA timezone data. Java and C++ examples support years 0000–9999 in UTC and the destination timezone.

Use this in a database

Convert between Unix timestamps and UTC database dates. MongoDB uses milliseconds; SQL examples return seconds. Each example includes both directions and a copy button.

Convert a time to generate an example.

Examples use UTC, regardless of the selected display timezone. MySQL / MariaDB changes the current connection’s timezone and uses a portable 1970–2038 range. PostgreSQL examples support years 1–9999; SQLite supports 0000–9999 and requires 3.42+. Database clients may display different trailing zeros. SQL Server requires 2016+ and supports years 1–9999. MongoDB examples support years 0000–9999; aggregation requires MongoDB 6.0+. Repeated local times get separate examples.

MySQL / MariaDB timestamp example

Unix timestamp 1700000000 represents2023-11-14T22:13:20.000Z. The example sets the connection timezone to UTC so the result does not depend on the database session’s timezone.

-- Set UTC for this connection before running both queries.
SET SESSION time_zone = '+00:00';

-- Unix seconds to a UTC datetime (fractional seconds preserved).
SELECT FROM_UNIXTIME(1700000000) AS utc_datetime;

-- UTC datetime back to Unix seconds.
SELECT UNIX_TIMESTAMP('2023-11-14 22:13:20.000') AS unix_seconds;

Expected UTC values: utc_datetime: 2023-11-14 22:13:20.000 unix_seconds: 1700000000

Seconds or milliseconds?

SQL examples return Unix seconds. MongoDB uses milliseconds: the same instant is 1700000000000. Select the input unit explicitly if automatic detection does not match your data.

Feedback

Have a suggestion, spotted a problem, or need another date format? Help shape what comes next for Timeplain.

For conversion issues, include your input, selected time zones, and the result you expected. Maximum 2,000 characters.

Your feedback and optional email are stored privately for review. Include your email if you would like a reply. Please don’t include passwords or other sensitive information.