@tpmjs/tools-date-parse
Parse dates from natural language text like "tomorrow at 3pm", "next Friday", "in 2 weeks", or "December 25th, 2024". Returns all found dates with their original text, ISO format, and Unix timestamps.
Test @tpmjs/tools-date-parse (dateParseTool) with AI-powered execution
0/2000 characters
Install this tool and use it with the AI SDK
npm install @tpmjs/tools-date-parsepnpm add @tpmjs/tools-date-parseyarn add @tpmjs/tools-date-parsebun add @tpmjs/tools-date-parsedeno add npm:@tpmjs/tools-date-parseimport { dateParseTool } from '@tpmjs/tools-date-parse';import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { dateParseTool } from '@tpmjs/tools-date-parse';
const result = await generateText({
model: openai('gpt-4o'),
tools: { dateParseTool },
prompt: 'Your prompt here...',
});
console.log(result.text);Available configuration options
textstringText containing one or more date/time expressions
referenceDatestringISO 8601 date string to use as reference for relative dates (e.g., "2024-01-15T10:00:00Z"). Defaults to current date/time.
strictbooleanUse strict parsing mode for more accurate results with fewer false positives (default: false)
Schema extracted: 1/1/2026, 8:18:35 AM
Parse dates in various natural language formats using chrono-node.
npm install @tpmjs/tools-date-parse
import { dateParseTool } from '@tpmjs/tools-date-parse'; const result = await dateParseTool.execute({ text: 'Meeting tomorrow at 3pm and follow-up next Friday' }); console.log(result.count); // => 2 console.log(result.dates[0]); // => { // parsed: "Thursday, January 16, 2025 at 3:00:00 PM EST", // original: "tomorrow at 3pm", // iso: "2025-01-16T20:00:00.000Z", // timestamp: 1737057600000 // }
// Use a custom reference date const result = await dateParseTool.execute({ text: 'in 2 weeks', referenceDate: '2024-01-01T00:00:00Z' }); // Use strict mode for fewer false positives const result = await dateParseTool.execute({ text: 'The year 2024 was great', strict: true });
MIT
Downloads/month
0
Quality Score