Timestamp Converter
A timestamp is a sequence of characters or encoded information identifying when a certain event occurred, usually giving date and time of day, sometimes accurate to a small fraction of a second. In computing, it often refers to the number of seconds or milliseconds that have elapsed since the Unix epoch (January 1, 1970, 00:00:00 UTC).
How to Get Current Timestamp in Various Languages
Here are code snippets demonstrating how to obtain the current Unix timestamp (seconds since epoch) or Unix milliseconds timestamp in popular programming languages.
JavaScript
Get current Unix timestamp (seconds):
Math.floor(Date.now() / 1000); // secondsGet current Unix milliseconds timestamp:
Date.now(); // millisecondsPython
Get current Unix timestamp (seconds):
import time
int(time.time()) # secondsGet current Unix milliseconds timestamp:
import time
int(time.time() * 1000) # millisecondsPHP
Get current Unix timestamp (seconds):
time(); // secondsGet current Unix milliseconds timestamp:
round(microtime(true) * 1000); // millisecondsJava
Get current Unix timestamp (seconds):
long unixSeconds = System.currentTimeMillis() / 1000L; // secondsGet current Unix milliseconds timestamp:
long unixMilliseconds = System.currentTimeMillis(); // millisecondsC#
Get current Unix timestamp (seconds):
long unixSeconds = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); // secondsGet current Unix milliseconds timestamp:
long unixMilliseconds = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); // milliseconds