• ARTICLE
  • STRING
  • CONVERTER
  • ENCRYPT
  • NETWORK
  • MORE
    CHART
    MATH
    COORDINATE
    IMAGE
    FILE
  • ARTICLE
    STRING
    CONVERTER
    ENCRYPT
    NETWORK
    MORE
    CHART
    MATH
    COORDINATE
    IMAGE
    FILE
logo Online Tools
4 Comments Favorite Copy Link Share

UNIX Timestamp Converter


  • Single Convert
  • Batch Convert
Local Time
UTC Time
Click to copy, for more time zones, please use batch conversion
Timestamp (Second)
Timestamp (Millisecond)
Click to copy
UNIX Timestamp Converter-summary

UNIX timestamps and time are converted to each other. UNIX timestamp (UNIX epoch, UNIX time, POSIX time or UNIX timestamp in English) is the number of seconds elapsed since January 1, 1970 (midnight of UTC / GMT), regardless of leap seconds.

UNIX Timestamp Converter-instructions

UNIX timestamp converter tool supports the mutual conversion of time and UNIX timestamp. Time displays local time (current time zone time) and UTC time. UNIX timestamps support second and millisecond units.

  1. Single Convert : Input a single Unix Timestamp and convert it to a time string. Input a single time string and convert it to Unix Timestamp.
    1. UNIX timestamp to time: fill in the timestamp to be converted in the timestamp input box. After filling in, select the timestamp unit. Click Convert to convert UNIX timestamp to time.
    2. Time to UNIX timestamp: fill in the time to be converted in the time input box. The supported time formats are 2022-01-10 19:21:59 and 2022-01-10 19:21:59.123, After filling in, click Convert to convert the time to UNIX timestamp.
  2. Batch Convert : Input multiple times or timestamps to convert time formats. The input and output timestamps support seconds and milliseconds. The input and output time support custom time formatting strings and time zones. Batch conversion supports local time and all UTC time zones.
    1. When converting batch time to timestamp, if the Time Format contains time zone information (Z or ZZ), the time zone information in the time format will be used, ignoring the selected time zone information in the Time Zone.
  3. Custom input format time format string.
    Field Example Description
    YY 01 Two-digit year
    YYYY 2001 Four-digit year
    M 1-12 Month, beginning at 1
    MM 01-12 Month, 2-digits
    MMM Jan-Dec The abbreviated month name
    MMMM January-December The full month name
    D 1-31 Day of month
    DD 01-31 Day of month, 2-digits
    H 0-23 Hours
    HH 00-23 Hours, 2-digits
    h 1-12 Hours, 12-hour clock
    hh 01-12 Hours, 12-hour clock, 2-digits
    m 0-59 Minutes
    mm 00-59 Minutes, 2-digits
    s 0-59 Seconds
    ss 00-59 Seconds, 2-digits
    S 0-9 Hundreds of milliseconds, 1-digit
    SS 00-99 Tens of milliseconds, 2-digits
    SSS 000-999 Milliseconds, 3-digits
    Z -05:00 The offset from UTC, ±HH:mm
    ZZ -0500 The offset from UTC, ±HHmm
    A AM PM Post or ante meridiem, upper-case
    a am pm Post or ante meridiem, lower-case
    Do 1st... 31st Day of Month with ordinal
    X 1410715640.579 Unix timestamp
    x 1410715640579 Unix ms timestamp
  4. Custom output format time format string.
    Field Example Description
    YY 01 Two-digit year
    YYYY 2001 Four-digit year
    M 1-12 Month, beginning at 1
    MM 01-12 Month, 2-digits
    MMM Jan-Dec The abbreviated month name
    MMMM January-December The full month name
    D 1-31 Day of month
    DD 01-31 Day of month, 2-digits
    d 0-6 The day of the week, with Sunday as 0
    dd Su-Sa The min name of the day of the week
    ddd Sun-Sat The short name of the day of the week
    dddd Sunday-Saturday The name of the day of the week
    H 0-23 Hours
    HH 00-23 Hours, 2-digits
    h 1-12 Hours, 12-hour clock
    hh 01-12 Hours, 12-hour clock, 2-digits
    m 0-59 Minutes
    mm 00-59 Minutes, 2-digits
    s 0-59 Seconds
    ss 00-59 Seconds, 2-digits
    SSS 000-999 Milliseconds, 3-digits
    Z -05:00 The offset from UTC, ±HH:mm
    ZZ -0500 The offset from UTC, ±HHmm
    A AM PM Post or ante meridiem, upper-case
    a am pm Post or ante meridiem, lower-case
    Q 1-4 Quarter
    Do 1st... 31st Day of Month with ordinal
    k 1-24 The hour, beginning at 1
    kk 01-24 The hour, 2-digits, beginning at 1
    X 1360013296 Unix Timestamp in second
    x 1360013296123 Unix Timestamp in millisecond

Get current timestamp in programming language

Lang Timestamp
Bash
date +%s
C
#include <stdio.h>
#include <time.h>

int main ()
{
    time_t seconds;

    seconds = time(NULL);
    printf("Seconds since January 1, 1970 = %ld\n", seconds);

    return(0);
}
C#
DateTime.Now.Subtract(new DateTime(1970, 1, 1))).TotalSeconds
C++
#include <iostream>
#include <ctime>

int main()
{
    std::time_t t = std::time(0);  // t is an integer type
    std::cout << t << " seconds since 01-Jan-1970\n";
    return 0;
}
Dart
(new DateTime.now().millisecondsSinceEpoch / 1000).truncate()
Golang
import (
  "time"
)
int64(time.Now().Unix())
Groovy
(new Date().time / 1000).longValue()
Dart
(new DateTime.now().millisecondsSinceEpoch / 1000).truncate()
Java
System.currentTimeMillis() / 1000
JavaScript
Math.round(new Date() / 1000)
Kotlin
System.currentTimeMillis() / 1000
Lua
os.time()
MySQL
SELECT unix_timestamp(now())
Objective-C
[[NSDate date] timeIntervalSince1970]
Perl
$currentTimestamp = time()
PHP
<?php

time();
Python
import time
time.time()
Ruby
Time.now.to_i
Rust
use std::time::{SystemTime, UNIX_EPOCH};

match SystemTime::now().duration_since(UNIX_EPOCH) {
    Ok(n) => println!("1970-01-01 00:00:00 UTC was {} seconds ago!", n.as_secs()),
    Err(_) => panic!("SystemTime before UNIX EPOCH!"),
}
Scala
val now = new Date()
println(now.getTime)
SQLite
SELECT strftime('%s', 'now')
TypeScript
let timestamp = Date.parse(new Date().toString()) / 1000;
console.log('timestamp: ' + timestamp);