Bagaimana cara mendapatkan waktu Unix saat ini dalam berbagai bahasa pemrograman?
Learn how to get the current Unix timestamp in different programming languages. Unix timestamp represents the number of seconds since January 1, 1970 UTC and is widely used in software development.
import time# Get the current timestampcurrent_timestamp = int(time.time())
// get the current timestampvar currentTimestamp = Math.floor(Date.now() / 1000);
long currentTimestamp = System.currentTimeMillis() / 1000;
long currentTimestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
#include <iostream>#include <chrono>int main() {auto now = std::chrono::system_clock::now();auto now_ms = std::chrono::time_point_cast<std::chrono::milliseconds>(now);auto epoch = now_ms.time_since_epoch();auto value = std::chrono::duration_cast<std::chrono::seconds>(epoch);std::cout << value.count() << std::endl;return 0;}
<?php$currentTimestamp = time();echo $currentTimestamp;?>
const currentTimestamp = Math.floor(Date.now() / 1000);
let currentTimestamp = Int(Date().timeIntervalSince1970)
current_timestamp = Time.now.to_i
package mainimport ("fmt""time")func main() {currentTimestamp := time.Now().Unix()fmt.Println(currentTimestamp)}