Unix and JavaScript timestamps
7 Sep 2025
Unix time is the number of seconds elapsed since midnight UTC on January 1, 1970. For example, Unix time was 1756684800 on September 1, 2025 at midnight UTC. The counter is independent of the time zone, holding the same value at the same moment in different timezones. It is widely used in C and C++ programming languages, databases (MySQL, PostgreSQL, and SQLite), and file systems (ext3, HFS+, and Reiserfs).
The counter is typically stored in a 32-bit signed integer, so it can represent dates from December 13, 1901 to January 19, 2038. In 2038, the counter will reach 231−1 and overflow, which is known as the year 2038 problem. Fortunately, most modern implementations have already switched to 64-bit integers.
Java and JavaScript use the number of milliseconds, not seconds, to represent time since 1970, resulting in a counter with more digits (e.g., 1756684800000) that fits in a 64-bit integer. Some other implementations (e.g., Apple File System) count the number of nanoseconds instead.
The Unix developers chose the epoch of January 1, 1970 because they created the first version of Unix in 1970, so they only needed to represent dates after 1970. Other platforms chose a date close to the introduction of the Gregorian calendar, for example, the Windows counter (the FILETIME structure) starts on January 1, 1601 and the UUID version 1 counter starts on October 15, 1582.
You can use the following functions in different programming languages to get the current Unix timestamp value:
- in C/C++, use
time_t timestamp = time(NULL); - in PHP, use
echo time(); - in Python, use:
import time, math
print(math.ceil(time.time()))
Math.ceil(Date.now() / 1000);long timestamp = System.currentTimeMillis() / 1000;import "time" timestamp := time.Now().Unix();
select unix_timestamp();select ceil(extract(epoch from current_timestamp));select strftime('%s');
Aba Search and Replace can convert Unix/JavaScript timestamps to a date in popular formats including ISO 8601 / RFC 3339, RFC 1123 / RFC 7231, and the Windows system format. It can also perform the reverse conversion and generate the current timestamp.
Stop jumping between browser tabs and random online tools. Aba Search and Replace is your Swiss army knife for fast, safe text updates across multiple files and data conversions, with all your data staying on your computer. Built for developers, testers, and analysts.
This is a blog about Aba Search and Replace, a tool for replacing text in multiple files.
- Unix and JavaScript timestamps
- Replace only the Nth match
- Aba 2.8 released
- Anonymizing a dataset by replacing names with counters
- Automatically add width and height to img tags
- Using zero-width assertions in regular expressions
- Aba 2.7 released
- Regular Expressions 101
- 2023 in review
- Regular expression for numbers
- Aba 2.6 released
- Search from the Windows command prompt
- Empty character class in JavaScript regexes
- Privacy Policy Update - December 2022
- Aba 2.5 released
- Our response to the war in Ukraine
- Check VAT ID with regular expressions and VIES
- Which special characters must be escaped in regular expressions?
- Aba 2.4 released
- Privacy Policy Update - April 2021
- Review of Aba Search and Replace with video
- Aba 2.2 released
- Discount on Aba Search and Replace
- Using search and replace to rename a method
- Cleaning the output of a converter
- Aba 2.1 released
- How to replace HTML tags using regular expressions
- Video trailer for Aba
- Aba 2.0 released
