| Language | Example Code | Action |
|---|---|---|
| JavaScript | Math.round(new Date() / 1000) |
|
| Python | import time; int(time.time()) |
|
| PHP | time() |
|
| Java | System.currentTimeMillis() / 1000 |
|
| C# | DateTimeOffset.UtcNow.ToUnixTimeSeconds() |
|
| Go | time.Now().Unix() |
|
| Ruby | Time.now.to_i |
|
| Swift | Int(Date().timeIntervalSince1970) |
|
| Objective-C | [[NSDate date] timeIntervalSince1970] |
|
| Shell | date +%s |
|
| Lua | os.time() |
|
| MySQL | SELECT UNIX_TIMESTAMP(); |
|
| SQLite | SELECT strftime('%s','now'); |
|
| Dart | (DateTime.now().millisecondsSinceEpoch / 1000).truncate() |
|
| Groovy | (new Date().time / 1000).toLong() |
Unix timestamps (also called Epoch time) represent time as the number of seconds since 00:00:00 UTC on January 1, 1970, known as the Unix epoch. They provide a standardized time format that allows different systems and platforms to synchronize, record events, calculate intervals, and perform time conversions in programming. Since timestamps are based on UTC, they are unaffected by time zones or daylight saving changes, making them suitable for global applications.
Unix timestamps come in two types: seconds (10-digit integers) and milliseconds (13-digit integers). A seconds-level timestamp like 1678901234 counts the seconds since the epoch, while a milliseconds-level timestamp like 1678901234567 counts milliseconds. Numeric timestamps are convenient for calculating differences, sorting, and transferring between systems without relying on local time, making them widely used in databases, logs, and development.
Most programming languages can easily obtain Unix timestamps, such as JavaScript's Math.round(new Date() / 1000), Python's int(time.time()), or PHP's time(). For human readability, timestamps are often converted to standard date and time formats, and the reverse conversion is common as well. Our online timestamp converter allows quick conversion between Unix timestamps and Beijing time, supporting both seconds and milliseconds.
Historically, Unix timestamps were stored as 32-bit integers, leading to the Year 2038 problem. Modern systems typically use 64-bit integers to cover a wider time range. Timestamps are widely used in website logs, data analysis, API synchronization, and programming, providing a unified, precise, and computable representation of time across platforms and time zones.
Convert time to timestamp or timestamp to time
Easier to use on mobile devices.