time
time(): int
Returns the current Unix timestamp in seconds.
C C23
C23
#include <stdio.h>
#include <time.h>
int main(void) {
printf("%s\n", time(NULL) > 1500000000 ? "true" : "false");
return 0;
}
Output
true
C++ C++26
C++26
#include <ctime>
#include <iostream>
int main() {
std::cout << std::boolalpha;
std::cout << ((long long)std::time(nullptr) > 1500000000) << "\n";
return 0;
}
Output
true
C# v11.0.100
v11.0.100
Console.WriteLine(DateTimeOffset.Now.ToUnixTimeSeconds() > 1500000000);
Output
True
Go v1.27.4
v1.27.4
package main
import (
"fmt"
"time"
)
func main() {
fmt.Println(time.Now().Unix() > 1500000000)
}
Output
true
Java v27.0.1
v27.0.1
public class Main {
public static void main(String[] args) {
System.out.println(System.currentTimeMillis() / 1000 > 1500000000);
}
}
Output
true
JavaScript v26.13.1
v26.13.1
console.log(Date.now() / 1000 > 1500000000)
Output
true
PHP v8.6.0
v8.6.0
echo time() > 1500000000 ? "true" : "false";
Output
true
Python v3.15.2
v3.15.2
import time
print(time.time() > 1500000000)
Output
True
Rust v1.99.1
v1.99.1
fn main() {
let secs = std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap().as_secs();
println!("{}", secs > 1500000000);
}
Output
true
TypeScript v26.13.1
v26.13.1
console.log(Date.now() / 1000 > 1500000000);
Output
true
Language differences
C: reads the current Unix timestamp with time(NULL).
JavaScript: Date.now() returns milliseconds and must be divided by 1000.
PHP: to keep the output deterministic, the examples compare against 1500000000 (any timestamp after 2017 passes).
Python: prints booleans as capitalized True.