Time/Timezone Utilities

Days In Month

Calculate exact days in any month, handling leap years automatically. Use via MCP in AI coding tools or REST API at `/v1/time/days-in-month`. Pass year and month (1-12) to get precise counts — February 2024 returns 29, February 2023 returns 28. Essential for date calculations and calendar logic.

API Endpoint

GET /v1/time/days-in-month

Code Examples

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

response = requests.get('https://tinyfn.io/v1/time/days-in-month',
    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 time/timezone tools:

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

Learn more about MCP setup →

FAQ

How do I get days in a specific month using MCP?

Call the days-in-month tool with year and month parameters. For example, year=2024, month=2 returns 29 days for February in a leap year.

Does this handle leap years correctly?

Yes, it automatically calculates leap years including century rules. February 2000 returns 29 days, but February 1900 returns 28 days.

What format should I use for the month parameter?

Use numeric values 1-12 where 1=January, 2=February, etc. String month names are not supported.

Can I get days for historical or future dates?

Yes, it works for any valid year. Useful for AI agents calculating date ranges, scheduling logic, or historical data analysis.

What happens if I pass invalid month numbers?

Invalid months (0, 13+) will return an error. Always validate month is between 1-12 before calling.

Try Days In Month Now

Get your free API key and start using Days In Month in seconds.

Get Free API Key