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

GET
https://daysfromepoch.com/api/now

Response Format

JSON
{
  "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

FieldDescription
unixUnix timestamp in seconds
unix_msUnix timestamp in milliseconds (JavaScript compatible)
isoISO 8601 formatted date string
day_from_epochNumber of days since January 1, 1970
utcBroken-down UTC time components

Usage Examples

JavaScript (Browser)
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);
  });
JavaScript (async/await)
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
curl https://daysfromepoch.com/api/now
Python
import requests

response = requests.get('https://daysfromepoch.com/api/now')
data = response.json()
print(f"Unix timestamp: {data['unix']}")
Go
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:

Response Headers
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.