In computing, Unix time (also known as POSIX time or Epoch time) is a system for describing instants in time, defined as the number of seconds that have elapsed since 00:00:00 Coordinated Universal Time (UTC), Thursday, 1 January 1970, not counting leap seconds.
Unix time, however is not a true representation of time, as it does not take into account leap seconds.
Leap seconds are added to UTC to keep it within 0.9 seconds of the mean solar time.
What is going to happen on January 19, 2038?
January 19, 2038 is a similar bug to Y2K. Unix time will get too large to be stored as a value in 32-bit signed integer and thus may cause many problems if the issue isnt fixed.
What is a time_t party?
A time_t pary is where Unix enthusiasts celebrate significant events of the Unix time value, for example, when the Unix time value reached 1,000,000; a time_t party was held by DKUUG (Danish Unix User Group) in Copenhagen, Denmark.
Here are some examples in different programming languages
Python:
import time
print(time.time())
JavaScript:
console.log(Date.now())
C++:
#include
#include
using namespace std;
int main() {
time_t now = time(0);
cout << now << endl;
}
C#:
using System;
class Program {
static void Main(string[] args) {
Console.WriteLine(DateTimeOffset.UtcNow.ToUnixTimeSeconds());
}
}
Java:
import java.time.Instant;
class Main {
public static void main(String[] args) {
System.out.println(Instant.now().getEpochSecond());
}
}
Go:
package main
import "fmt"
import "time"
func main() {
fmt.Println(time.Now().Unix())
}
Rust:
use std::time;
fn main() {
println!("{}", time::SystemTime::now().duration_since(time::UNIX_EPOCH).unwrap().as_secs());
}
Swift:
import Foundation
print(Int(Date().timeIntervalSince1970))
Kotlin:
import java.time.Instant
fun main() {
println(Instant.now().epochSecond)
}