Unix epoch to date
Convert unix epoch to human-readable date
Timestamp Type | : Seconds |
GMT | : December 22, 2024 at 5:20:16 PM UTC |
Your Time Zone | : December 22, 2024 at 5:20:16 PM UTC |
Relative | : 0 seconds ago |
Date to Epoch
Convert human-readable date to Epoch
Epoch Timestamp | : 1734888016 |
Epoch Milliseconds | : 1734888016074 |
Relative | : in 0 seconds |
What is Epoch
The concept of the Unix epoch, also referred to as Unix time, POSIX time, or Unix timestamp, denotes the count of seconds elapsed since January 1, 1970 (midnight UTC/GMT), excluding leap seconds (ISO 8601: 1970-01-01T00:00:00Z). While technically pinpointing Unix time 0 (midnight 1/1/1970), the term 'epoch' is commonly used synonymously with Unix time.
Example
Here are some conversions of common time intervals to seconds and milliseconds.
Time | Seconds (s) | MilliSeconds (ms) |
---|---|---|
1 Hour | 3,600 Seconds | 3,600,000 MilliSeconds |
1 Day | 86,400 Seconds | 86,400,000 MilliSeconds |
1 Week | 604,800 Seconds | 604,800,000 MilliSeconds |
1 Year | 31,556,926 Seconds | 31,556,952,000 MilliSeconds |
How to get current Epoch in various tools
Here are some examples of how to get the current epoch in various programming languages and tools.
Language | Snippet |
---|---|
Javascript | Math.floor(new Date().getTime()/1000) |
Python | import time; print(int(time.time())) |
Java | System.out.println(System.currentTimeMillis() / 1000); |
Go | fmt.Println(time.Now().Unix()) |
Ruby | puts Time.now.to_i |
PHP | echo time(); |
C# | Console.WriteLine((DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds); |
Swift | print(Int(NSDate().timeIntervalSince1970)) |
Kotlin | println(System.currentTimeMillis() / 1000) |
Rust | println!("{}", SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs()); |
C | printf("%ld\n", (long)time(NULL)); |
C++ | std::cout << std::time(0) << std::endl; |
Perl | print time; |
Linux/Unix | date +%s |
Postgres | SELECT extract(epoch from now()); |
MySQL | SELECT UNIX_TIMESTAMP(); |
Oracle | SELECT (SYSDATE - TO_DATE('1970-01-01', 'YYYY-MM-DD')) * 86400 FROM DUAL; |
SQL Server | SELECT DATEDIFF(s, '1970-01-01 00:00:00', GETUTCDATE()); |