NowUTC.com

UTC Time in Code

The current UTC time, the current Unix epoch and epoch-to-date conversion in 15 languages, databases and shells. Every snippet is standard library unless noted. The examples convert 1767225600, which is 2026-01-01T00:00:00Z. Not sure why UTC? Read What is UTC?

UTC right now --:--

JavaScript / TypeScript

// Current UTC time, ISO 8601
new Date().toISOString();                     // "2026-01-01T00:00:00.000Z"

// Current Unix epoch (seconds)
Math.floor(Date.now() / 1000);

// Epoch seconds to a UTC date
new Date(1767225600 * 1000).toISOString();    // "2026-01-01T00:00:00.000Z"

Date always stores UTC internally; only methods like toString() and getHours() use the local zone.

Python

from datetime import datetime, timezone

# Current UTC time, ISO 8601
datetime.now(timezone.utc).isoformat()       # '2026-01-01T00:00:00.000000+00:00'

# Current Unix epoch (seconds)
int(datetime.now(timezone.utc).timestamp())

# Epoch seconds to a UTC date
datetime.fromtimestamp(1767225600, tz=timezone.utc)

Avoid datetime.utcnow(): it returns a naive value with no zone attached and is deprecated since Python 3.12.

Java / Kotlin

import java.time.Instant;

// Current UTC time, ISO 8601
Instant.now().toString();                    // "2026-01-01T00:00:00.123Z"

// Current Unix epoch (seconds)
Instant.now().getEpochSecond();

// Epoch seconds to a UTC date
Instant.ofEpochSecond(1767225600L);          // 2026-01-01T00:00:00Z

java.time.Instant is always UTC. Kotlin on the JVM uses the same calls.

C# / .NET

// Current UTC time, ISO 8601 (round-trip format)
DateTime.UtcNow.ToString("o");               // "2026-01-01T00:00:00.0000000Z"

// Current Unix epoch (seconds)
DateTimeOffset.UtcNow.ToUnixTimeSeconds();

// Epoch seconds to a UTC date
DateTimeOffset.FromUnixTimeSeconds(1767225600).UtcDateTime;

Prefer DateTimeOffset for stored values: it keeps the offset, so a value can never be mistaken for local time.

Go

import "time"

// Current UTC time, RFC 3339
time.Now().UTC().Format(time.RFC3339)        // "2026-01-01T00:00:00Z"

// Current Unix epoch (seconds)
time.Now().Unix()

// Epoch seconds to a UTC date
time.Unix(1767225600, 0).UTC()

Rust

use std::time::{SystemTime, UNIX_EPOCH};

// Current Unix epoch (seconds), standard library
let secs = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs();

// ISO 8601 and epoch-to-date need the chrono crate
let now = chrono::Utc::now().to_rfc3339();   // "2026-01-01T00:00:00.000000000+00:00"
let date = chrono::DateTime::from_timestamp(1767225600, 0);

The standard library has no calendar type; chrono (or time) is the usual choice.

PHP

// Current UTC time, ISO 8601
gmdate('c');                                 // "2026-01-01T00:00:00+00:00"

// Current Unix epoch (seconds)
time();

// Epoch seconds to a UTC date
gmdate('Y-m-d\TH:i:s\Z', 1767225600);        // "2026-01-01T00:00:00Z"

The gm functions ignore date.timezone; plain date() uses it.

Ruby

require 'time'

# Current UTC time, ISO 8601
Time.now.utc.iso8601                         # "2026-01-01T00:00:00Z"

# Current Unix epoch (seconds)
Time.now.to_i

# Epoch seconds to a UTC date
Time.at(1767225600).utc

Swift

import Foundation

// Current UTC time, ISO 8601
ISO8601DateFormatter().string(from: Date())  // "2026-01-01T00:00:00Z"

// Current Unix epoch (seconds)
Int(Date().timeIntervalSince1970)

// Epoch seconds to a date
Date(timeIntervalSince1970: 1767225600)

ISO8601DateFormatter formats in UTC unless you set its timeZone.

SQL Server

-- Current UTC time (datetime2)
SELECT SYSUTCDATETIME();

-- Current Unix epoch (seconds)
SELECT DATEDIFF_BIG(SECOND, '1970-01-01', SYSUTCDATETIME());

-- Epoch seconds to a UTC date
SELECT DATEADD(SECOND, 1767225600, CAST('1970-01-01' AS datetime2));

GETDATE() and SYSDATETIME() return the server's local time; use the UTC versions for stored values.

PostgreSQL

-- Current UTC time
SELECT now() AT TIME ZONE 'UTC';

-- Current Unix epoch (seconds)
SELECT extract(epoch FROM now())::bigint;

-- Epoch seconds to a timestamp with time zone
SELECT to_timestamp(1767225600);

Store timestamptz: PostgreSQL keeps it in UTC and converts on display using the session's TimeZone.

MySQL / MariaDB

-- Current UTC time
SELECT UTC_TIMESTAMP();

-- Current Unix epoch (seconds)
SELECT UNIX_TIMESTAMP();

-- Epoch seconds to a date (in the session time zone)
SET time_zone = '+00:00';
SELECT FROM_UNIXTIME(1767225600);

FROM_UNIXTIME() and NOW() follow the session time_zone; set it to '+00:00' to work in UTC.

SQLite

-- Current UTC time, ISO 8601
SELECT strftime('%Y-%m-%dT%H:%M:%SZ', 'now');

-- Current Unix epoch (seconds), SQLite 3.38+
SELECT unixepoch();

-- Epoch seconds to a UTC date
SELECT datetime(1767225600, 'unixepoch');

SQLite's date functions work in UTC by default.

Bash (Linux and macOS)

# Current UTC time, ISO 8601
date -u +%Y-%m-%dT%H:%M:%SZ

# Current Unix epoch (seconds)
date +%s

# Epoch seconds to a UTC date
date -u -d @1767225600      # GNU / Linux
date -u -r 1767225600       # macOS / BSD

PowerShell

# Current UTC time, ISO 8601
(Get-Date).ToUniversalTime().ToString('o')

# Current Unix epoch (seconds)
[DateTimeOffset]::UtcNow.ToUnixTimeSeconds()

# Epoch seconds to a UTC date
[DateTimeOffset]::FromUnixTimeSeconds(1767225600).UtcDateTime

Frequently asked questions

How do I get the current UTC time in JavaScript?

Call new Date().toISOString(). It returns an ISO 8601 string in UTC, such as 2026-01-01T00:00:00.000Z. For the Unix epoch in seconds, use Math.floor(Date.now() / 1000).

How do I get the current UTC time in Python?

Use datetime.now(timezone.utc) from the datetime module. It returns a time-zone-aware value; avoid datetime.utcnow(), which is naive and deprecated since Python 3.12.

Is the Unix epoch always UTC?

Yes. A Unix timestamp counts seconds since 1970-01-01T00:00:00Z and has no time zone. Only converting it to a readable date involves a zone, so convert with a UTC function to get UTC.

Should I store timestamps in UTC?

Yes. Store UTC (or a type that keeps the offset, such as timestamptz or DateTimeOffset) and convert to the reader's time zone only when displaying it. That avoids daylight saving gaps and makes values from different servers comparable.

Open the UTC clock Copy formats reference