Date/Time Utilities

Day Of Year

Converts any date to its day-of-year number (1-366). Access via MCP in Cursor or Windsurf for AI agent date calculations, or call GET /v1/datetime/day-of-year directly. Input "2024-07-15" returns 197. Handles leap years automatically — February 29th becomes day 60, shifting all subsequent days forward by one.

API Endpoint

GET /v1/datetime/day-of-year

Code Examples

curl "https://tinyfn.io/v1/datetime/day-of-year" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/datetime/day-of-year', {
  headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
const data = await response.json();
console.log(data);
import requests

response = requests.get('https://tinyfn.io/v1/datetime/day-of-year',
    headers={'X-API-Key': 'YOUR_API_KEY'})
data = response.json()
print(data)

Use via MCP

Add to your AI agent

Connect your AI agent (Claude, Cursor, Windsurf, etc.) to TinyFn's date/time tools:

{
  "mcpServers": {
    "tinyfn-datetime": {
      "url": "https://tinyfn.io/mcp/datetime",
      "headers": {
        "X-API-Key": "YOUR_API_KEY"
      }
    }
  }
}

Learn more about MCP setup →

FAQ

How do I get the day of year for a specific date?

Send a GET request to /v1/datetime/day-of-year with your date parameter, or use the MCP tool in supported AI editors. Returns an integer from 1-366.

Does day of year calculation handle leap years correctly?

Yes, it automatically accounts for leap years. In leap years, February 29th is day 60, and all dates after February get shifted up by one day number.

What date formats are supported for day of year conversion?

Accepts standard ISO date formats like YYYY-MM-DD. For example, '2024-12-31' returns 366 in a leap year, 365 in a regular year.

Can MCP agents use day of year for date range calculations?

Absolutely. AI agents in Cursor or Claude Code can calculate date spans, seasonal patterns, or fiscal year positions using deterministic day-of-year values.

What's the difference between day of year and day of week?

Day of year counts from January 1st (1-366), while day of week cycles through Monday-Sunday. Day 100 might be a Tuesday, depending on the year.

Try Day Of Year Now

Get your free API key and start using Day Of Year in seconds.

Get Free API Key