To the Top

Unix Timestamp Converter (The Javascript Online Tool)

Buy Me A Coffee

Unix Timestamp represents the number of seconds since 1st Jan, 1970 (00:00:00: GMT). It has been used widely in many Operating System.

Current Time:

Convert Unix TimeStamp to Date String

Unix Timestamp: Date String:

Convert Date String to TimeStamp

Date String: Unix Timestamp:

Unix TimeStamp Converter Application Programming Interface (API)

We provide a simple API to allow easy conversion between the unix timestamp and the date string (formatted as "Y-m-d h:i:s").

To Convert From Date String to Unix TimeStamp

API example:
  https://helloacm.com/api/unix-timestamp-converter/?cached&s=2016-01-01%202:3:22
returns: 
  1451613802

To Convert From Unix TimeStamp to Date String

API example:
  https://helloacm.com/api/unix-timestamp-converter/?cached&s=1451613802
returns:
  "2016-01-01 02:03:22"

Invalid Date String

API example:
  https://helloacm.com/api/unix-timestamp-converter/?cached&s=asdfasd
returns:
  false

API Core Source Code in PHP

if (is_numeric($s)) {
  $data = date("Y-m-d h:i:s", (integer)$s);
} else {
  $data = strtotime($s);
}

Unix TimeStamps in Programming Languages

Most programming languages provide easy ways to obtain the unix timestamps. The following shows a few programming languages and the way to obtain the time stamp.

Python

time.time()

Ruby

Time.now.to_i

Shell

date +%s

Swift

NSDate().timeIntervalSince1970

JavaScript

Math.round(new Date()*0.001)

MySQL

SELECT unix_timestamp(now())

Objective-C

[[NSDate date] timeIntervalSince1970]

SQLite

SELECT strftime('%s', 'now')

Erlang

calendar:datetime_to_gregorian_seconds(calendar:universal_time())-719528*24*3600.

PHP

time()

Go

int32(time.Now().Unix())

Java

(int)(System.currentTimeMillis()*0.001)

Share: List of Many Other Online Tools