Unix Timestamp & Epoch Converter
Convert Unix timestamps to human-readable dates instantly. Professional tool for developers and system administrators.
Wednesday, June 4th 2025, 4:14:48 PM
Timestamp to Date
UTC Time:
Your Local Time:
Date to Timestamp
Unix Timestamp:
Milliseconds:
Seconds to Duration
Duration:
Day Start & End Timestamps
Start of Day:
End of Day:
What is Unix Timestamp?
Unix timestamp (also known as Epoch time or POSIX time) is a system for tracking time as a running total of seconds since January 1, 1970, 00:00:00 UTC. This date is called the "Unix Epoch."
Universal Standard
Used across all computing platforms and programming languages for consistent time representation.
Easy Calculations
Simple arithmetic operations for time differences, comparisons, and scheduling.
Timezone Independent
Represents a single moment in time regardless of location or timezone.
Why Use Unix Timestamps?
- Database Storage: Efficient storage of datetime information
- API Communication: Standard format for data exchange
- Log Files: Consistent timestamping across systems
- Programming: Easy date arithmetic and comparisons
- System Administration: File timestamps and process monitoring
⚠️ Year 2038 Problem
32-bit systems will face an overflow issue on January 19, 2038, at 03:14:07 UTC. Modern 64-bit systems have resolved this limitation.
Time Units Reference
1 Minute
1 Hour
1 Day
1 Week
1 Month (30.44 days)
1 Year (365.24 days)
Time Period | Seconds | Minutes | Hours |
---|---|---|---|
1 Minute | 60 | 1 | 0.017 |
1 Hour | 3,600 | 60 | 1 |
1 Day | 86,400 | 1,440 | 24 |
1 Week | 604,800 | 10,080 | 168 |
1 Month (30.44 days) | 2,629,744 | 43,829.067 | 730.484 |
1 Year (365.24 days) | 31,556,926 | 525,948.767 | 8,765.813 |
Convert Date to Timestamp
PHP
// Convert human-readable date to Unix timestamp
strtotime("June 4, 2025");
// Result: 1749042888
// Alternative formats
strtotime("06/04/2025");
strtotime("+10 days"); // 10 days from now
// Object-oriented approach
$date = new DateTime('06/04/2025');
echo $date->format('U'); // Unix timestamp
// With timezone
$date = new DateTime('06/04/2025', new DateTimeZone('UTC'));
$timestamp = $date->getTimestamp();
JavaScript
// Convert date string to Unix timestamp
const myDate = new Date("June 04, 2025 16:14:48");
const myEpoch = Math.floor(myDate.getTime() / 1000);
console.log(myEpoch); // 1749042888
// Using Date.parse()
const timestamp = Math.floor(Date.parse("2025-06-04") / 1000);
// From individual components
const date = new Date(2025, 5, 4, 16, 14, 48);
const epoch = Math.floor(date.getTime() / 1000);
// Current timestamp
const now = Math.floor(Date.now() / 1000);
Python
import calendar
import time
from datetime import datetime
# Convert date string to Unix timestamp
date_string = '2025-06-04 16:14:48'
timestamp = calendar.timegm(time.strptime(date_string, '%Y-%m-%d %H:%M:%S'))
print(timestamp) # 1749042888
# Using datetime module
dt = datetime(2025, 6, 4, 16, 14, 48)
timestamp = int(dt.timestamp())
# Current timestamp
import time
current_timestamp = int(time.time())
Java
import java.time.*;
import java.time.format.DateTimeFormatter;
// Convert date string to Unix timestamp
String dateString = "2025-06-04 16:14:48";
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime dateTime = LocalDateTime.parse(dateString, formatter);
long timestamp = dateTime.atZone(ZoneId.of("UTC")).toEpochSecond();
System.out.println(timestamp); // 1749042888
// From individual components
LocalDateTime dt = LocalDateTime.of(2025, 6, 4, 16, 14, 48);
long epochSecond = dt.toEpochSecond(ZoneOffset.UTC);
// Current timestamp
long currentTimestamp = Instant.now().getEpochSecond();
C#
using System;
// Convert DateTime to Unix timestamp
DateTime dateTime = new DateTime(2025, 6, 4, 16, 14, 48, DateTimeKind.Utc);
long timestamp = ((DateTimeOffset)dateTime).ToUnixTimeSeconds();
Console.WriteLine(timestamp); // 1749042888
// From string
DateTime parsedDate = DateTime.Parse("2025-06-04 16:14:48");
long unixTime = ((DateTimeOffset)parsedDate.ToUniversalTime()).ToUnixTimeSeconds();
// Current timestamp
long currentTimestamp = DateTimeOffset.Now.ToUnixTimeSeconds();
// Alternative using TimeSpan
DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
long timestamp2 = (long)(dateTime - epoch).TotalSeconds;
Go
package main
import (
"fmt"
"time"
)
func main() {
// Convert date to Unix timestamp
layout := "2006-01-02 15:04:05"
dateString := "2025-06-04 16:14:48"
t, _ := time.Parse(layout, dateString)
timestamp := t.Unix()
fmt.Println(timestamp) // 1749042888
// From individual components
date := time.Date(2025, time.Month(6), 4, 16, 14, 48, 0, time.UTC)
unixTime := date.Unix()
// Current timestamp
currentTimestamp := time.Now().Unix()
fmt.Println(currentTimestamp)
}
Swift
import Foundation
// Convert date string to Unix timestamp
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
dateFormatter.timeZone = TimeZone(abbreviation: "UTC")
if let date = dateFormatter.date(from: "2025-06-04 16:14:48") {
let timestamp = Int(date.timeIntervalSince1970)
print(timestamp) // 1749042888
}
// From Date components
let calendar = Calendar.current
let components = DateComponents(year: 2025, month: 6, day: 4,
hour: 16, minute: 14, second: 48)
if let date = calendar.date(from: components) {
let unixTime = Int(date.timeIntervalSince1970)
}
// Current timestamp
let currentTimestamp = Int(Date().timeIntervalSince1970)
Rust
use chrono::{DateTime, Utc, NaiveDateTime, TimeZone};
// Convert date string to Unix timestamp
let date_str = "2025-06-04 16:14:48";
let naive_dt = NaiveDateTime::parse_from_str(date_str, "%Y-%m-%d %H:%M:%S").unwrap();
let dt: DateTime<Utc> = Utc.from_utc_datetime(&naive_dt);
let timestamp = dt.timestamp();
println!("{}", timestamp); // 1749042888
// From individual components
let dt = Utc.ymd(2025, 6, 4).and_hms(16, 14, 48);
let unix_time = dt.timestamp();
// Current timestamp
let now = Utc::now();
let current_timestamp = now.timestamp();
// Using std::time
use std::time::{SystemTime, UNIX_EPOCH};
let duration = SystemTime::now().duration_since(UNIX_EPOCH).unwrap();
let timestamp_std = duration.as_secs();
Convert Timestamp to Date
PHP
// Convert Unix timestamp to human-readable date
$epoch = 1749042888;
$dt = new DateTime("@$epoch");
echo $dt->format('Y-m-d H:i:s'); // 2025-06-04 16:14:48
// With timezone
$dt->setTimezone(new DateTimeZone('America/New_York'));
echo $dt->format('Y-m-d H:i:s T');
// Using date() function
echo date('Y-m-d H:i:s', $epoch);
echo date('l, F j, Y g:i A', $epoch); // Full format
// Different formats
echo date('c', $epoch); // ISO 8601 format
echo date('r', $epoch); // RFC 2822 format
JavaScript
// Convert Unix timestamp to Date object
const timestamp = 1749042888;
const myDate = new Date(timestamp * 1000);
console.log(myDate.toString());
// Wed Jun 04 2025 16:14:48 GMT+0300
// Custom formatting
const year = myDate.getFullYear();
const month = String(myDate.getMonth() + 1).padStart(2, '0');
const day = String(myDate.getDate()).padStart(2, '0');
const formatted = `${year}-${month}-${day}`;
// Using toLocaleString for different formats
console.log(myDate.toLocaleString()); // Local format
console.log(myDate.toISOString()); // ISO format
console.log(myDate.toUTCString()); // UTC format
// Custom locale formatting
const options = { year: 'numeric', month: 'long', day: 'numeric', hour: '2-digit', minute: '2-digit' };
console.log(myDate.toLocaleDateString('en-US', options));
Python
import time
from datetime import datetime, timezone
# Convert Unix timestamp to human-readable date
timestamp = 1749042888
dt = datetime.fromtimestamp(timestamp, tz=timezone.utc)
print(dt.strftime('%Y-%m-%d %H:%M:%S')) # 2025-06-04 16:14:48
# Using time module
formatted_time = time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime(timestamp))
print(formatted_time)
# Different formats
print(dt.strftime('%B %d, %Y at %I:%M %p')) # Full format
print(dt.isoformat()) # ISO format
print(dt.strftime('%A, %B %d, %Y')) # Day and date
# Local timezone
local_dt = datetime.fromtimestamp(timestamp)
print(f"Local time: {local_dt.strftime('%Y-%m-%d %H:%M:%S')}")
Java
import java.time.*;
import java.time.format.DateTimeFormatter;
// Convert Unix timestamp to LocalDateTime
long timestamp = 1749042888L;
Instant instant = Instant.ofEpochSecond(timestamp);
LocalDateTime dateTime = LocalDateTime.ofInstant(instant, ZoneOffset.UTC);
System.out.println(dateTime); // 2025-06-04T16:14:48
// Custom formatting
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String formatted = dateTime.format(formatter);
System.out.println(formatted);
// Different time zones
ZonedDateTime nyTime = instant.atZone(ZoneId.of("America/New_York"));
ZonedDateTime londonTime = instant.atZone(ZoneId.of("Europe/London"));
// Various formats
DateTimeFormatter fullFormatter = DateTimeFormatter.ofPattern("EEEE, MMMM d, yyyy 'at' h:mm a");
System.out.println(dateTime.format(fullFormatter));
C#
using System;
// Convert Unix timestamp to DateTime
long timestamp = 1749042888;
DateTime dateTime = DateTimeOffset.FromUnixTimeSeconds(timestamp).DateTime;
Console.WriteLine(dateTime.ToString("yyyy-MM-dd HH:mm:ss")); // 2025-06-04 16:14:48
// With timezone info
DateTimeOffset dto = DateTimeOffset.FromUnixTimeSeconds(timestamp);
Console.WriteLine(dto.ToString("yyyy-MM-dd HH:mm:ss zzz"));
// Different formats
Console.WriteLine(dateTime.ToString("F")); // Full date/time
Console.WriteLine(dateTime.ToString("D")); // Long date
Console.WriteLine(dateTime.ToString("T")); // Long time
// Custom format
string customFormat = dateTime.ToString("dddd, MMMM dd, yyyy 'at' h:mm tt");
Console.WriteLine(customFormat);
// UTC conversion
DateTime utcDateTime = dateTime.ToUniversalTime();
Ruby
# Convert Unix timestamp to Time object
timestamp = 1749042888
time = Time.at(timestamp).utc
puts time.strftime('%Y-%m-%d %H:%M:%S') # 2025-06-04 16:14:48
# Different formats
puts time.strftime('%A, %B %d, %Y at %I:%M %p') # Full format
puts time.strftime('%c') # Complete date and time
puts time.iso8601 # ISO 8601 format
# Local timezone
local_time = Time.at(timestamp)
puts "Local: #{local_time.strftime('%Y-%m-%d %H:%M:%S %Z')}"
# Using DateTime
require 'date'
dt = DateTime.strptime(timestamp.to_s, '%s')
puts dt.strftime('%Y-%m-%d %H:%M:%S')
Kotlin
import java.time.*
import java.time.format.DateTimeFormatter
// Convert Unix timestamp to LocalDateTime
val timestamp = 1749042888L
val instant = Instant.ofEpochSecond(timestamp)
val dateTime = LocalDateTime.ofInstant(instant, ZoneOffset.UTC)
println(dateTime) // 2025-06-04T16:14:48
// Custom formatting
val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")
val formatted = dateTime.format(formatter)
println(formatted)
// Different time zones
val nyTime = instant.atZone(ZoneId.of("America/New_York"))
val londonTime = instant.atZone(ZoneId.of("Europe/London"))
// Using extension functions
fun Long.toLocalDateTime(): LocalDateTime =
LocalDateTime.ofInstant(Instant.ofEpochSecond(this), ZoneOffset.UTC)
val dt = timestamp.toLocalDateTime()
println("Formatted: ${dt.format(formatter)}")
Perl
#!/usr/bin/perl
use strict;
use warnings;
use POSIX qw(strftime);
# Convert Unix timestamp to human-readable date
my $timestamp = 1749042888;
my $formatted = strftime("%Y-%m-%d %H:%M:%S", gmtime($timestamp));
print "$formatted\n"; # 2025-06-04 16:14:48
# Different formats
print strftime("%A, %B %d, %Y at %I:%M %p", gmtime($timestamp)) . "\n";
print strftime("%c", gmtime($timestamp)) . "\n"; # Complete format
# Local time
my $local_formatted = strftime("%Y-%m-%d %H:%M:%S %Z", localtime($timestamp));
print "Local: $local_formatted\n";
# Using DateTime module (if available)
use DateTime;
my $dt = DateTime->from_epoch(epoch => $timestamp);
print $dt->strftime('%Y-%m-%d %H:%M:%S') . "\n";
Frequently Asked Questions
What is the difference between Unix timestamp and other time formats?
Unix timestamp is a single number representing seconds since January 1, 1970, making it universal and timezone-independent. Other formats like ISO 8601 are human-readable but more complex to process programmatically.
How do I convert milliseconds to Unix timestamp?
Divide the milliseconds by 1000. For example: 1609459200000 ÷ 1000 = 1609459200 Unix timestamp (January 1, 2021).
Why does my timestamp show a different time than expected?
Unix timestamps are always in UTC. If you see a different time, it's likely being displayed in your local timezone. Always consider timezone conversions when working with timestamps.
Can Unix timestamps represent dates before 1970?
Yes, negative Unix timestamps represent dates before January 1, 1970. For example: -86400 represents December 31, 1969.