Public API
EpochDays provides a free, CORS-enabled JSON API that returns the current timestamp in multiple formats. Use it in your applications to get the current Unix timestamp, ISO date, and day from epoch.
Endpoint
https://daysfromepoch.com/api/now
Response Format
{
"unix": 1704067200,
"unix_ms": 1704067200000,
"iso": "2024-01-01T00:00:00.000Z",
"day_from_epoch": 19723,
"utc": {
"year": 2024,
"month": 1,
"day": 1,
"hour": 0,
"minute": 0,
"second": 0
}
}Response Fields
| Field | Description |
|---|---|
unix | Unix timestamp in seconds |
unix_ms | Unix timestamp in milliseconds (JavaScript compatible) |
iso | ISO 8601 formatted date string |
day_from_epoch | Number of days since January 1, 1970 |
utc | Broken-down UTC time components |
Usage Examples
fetch('https://daysfromepoch.com/api/now')
.then(response => response.json())
.then(data => {
console.log('Current Unix timestamp:', data.unix);
console.log('Day from epoch:', data.day_from_epoch);
});const response = await fetch('https://daysfromepoch.com/api/now');
const data = await response.json();
console.log(data.iso); // "2024-01-01T00:00:00.000Z"curl https://daysfromepoch.com/api/now
import requests
response = requests.get('https://daysfromepoch.com/api/now')
data = response.json()
print(f"Unix timestamp: {data['unix']}")resp, err := http.Get("https://daysfromepoch.com/api/now")
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println("Unix:", result["unix"])CORS Support
The API includes CORS headers, allowing you to call it directly from browser JavaScript on any domain:
Access-Control-Allow-Origin: * Access-Control-Allow-Methods: GET, OPTIONS Access-Control-Allow-Headers: Content-Type Cache-Control: no-store, max-age=0
Rate Limiting
There are currently no rate limits, but please be reasonable with your usage. For high-frequency polling, consider caching responses for at least 1 second. If you need sub-second precision, use your local system time and sync periodically.
Frequently Asked Questions
Is this API free to use?
Yes, the API is completely free. There are no rate limits for reasonable usage. For high-volume applications, please consider self-hosting or caching responses.
Can I use this API from a browser?
Yes! CORS headers are enabled, so you can call the API directly from JavaScript running in any browser.
What is day_from_epoch?
The day_from_epoch value represents the number of complete days that have elapsed since January 1, 1970 (the Unix epoch). For example, January 2, 1970 would be day 1.
How accurate is the timestamp?
The timestamp is generated server-side when your request is processed. Network latency means there may be a small delay between the timestamp and when you receive it.