• 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


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. 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.

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);