Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Date Parser

Date Parser Laravel Package

thbm/date-parser

A Laravel-friendly date parser that turns messy, human-written date and time strings into clean, structured values you can work with. Handy for imports, forms, and anywhere users type dates in their own way, with straightforward parsing you can drop into existing PHP and Laravel projects.

Deep Wiki
Context7

thbm/date-parser is a lightweight Laravel/PHP package for turning human-readable date and time strings into structured DateTime/Carbon instances. It gives your application a single, predictable entry point for parsing relative dates, formatted strings, and common shorthand expressions, keeping controllers and services free of scattered strtotime() calls.

  • Flexible parsing of natural-language and formatted date strings
  • Returns Carbon instances ready for formatting and arithmetic
  • Framework-agnostic core with optional Laravel integration
  • Clear exceptions for invalid or ambiguous input
  • Configurable default timezone and fallback values
Frequently asked questions about Date Parser
How do I install thbm/date-parser in a Laravel app?
Install it with Composer using composer require thbm/date-parser. In Laravel, if the package includes a service provider it is typically auto-discovered; otherwise you can use the parser class directly. Run composer dump-autoload if you add it manually to an existing project.
What kinds of date strings can thbm/date-parser handle?
It is built to parse date and time strings using multiple formats, including human-friendly input rather than a single rigid pattern. You typically provide candidate formats or rely on the package's supported format handling. Check the README and tests for exact format syntax and limitations.
Does thbm/date-parser return Carbon or native DateTime objects?
The package is described as returning Carbon or DateTime objects, so you can choose the one that fits your codebase. Carbon is usually preferred in Laravel because it integrates with framework helpers and time-travel testing. Native DateTime is useful when you want fewer dependencies or are working outside Laravel.
Which Laravel versions does thbm/date-parser support?
The provided package context does not list a Laravel version constraint, so check the require section of its composer.json before installing. Look specifically for illuminate/support or laravel/framework requirements. If your app uses an older Laravel release, test in a branch first.
Can I use thbm/date-parser outside Laravel in plain PHP?
Yes, it is a PHP package and the description does not tie parsing to Laravel-specific features. You can install it via Composer and instantiate the parser in any PHP project. Laravel integration mainly matters for service provider auto-discovery and Carbon helpers.
How should I handle invalid or ambiguous date input with thbm/date-parser?
Wrap parsing in a try/catch and return a validation error when no format matches. Ambiguous input like 01/02/2024 should be resolved by passing explicit formats or by defining your preferred order. In Laravel, combine parsing with form request validation so bad input never reaches your domain logic.
Is there any configuration file I need to publish for thbm/date-parser?
The package is described as simple and lightweight, so it may not require configuration beyond the formats you pass in. If a config file is available, the README will show the publish command, typically php artisan vendor:publish. Do not assume configuration exists until you confirm it in the package docs.
How do I test code that uses thbm/date-parser?
Freeze or set the current time with Carbon::setTestNow so relative strings like tomorrow produce stable results. Assert the returned object type and formatted value rather than comparing object instances. Include cases for each format you support and for invalid input.
What are the production concerns with flexible date parsing?
Flexible parsing can be non-deterministic if format order or timezone is unclear, so define accepted formats and a default timezone explicitly. Validate input at the boundary and log parse failures without exposing raw user input. Also pin the package version and run your test suite after Composer updates.
What alternatives should I consider before adding thbm/date-parser?
PHP's DateTime::createFromFormat and Carbon's parse helpers can cover many of the same cases without an extra package. Laravel's date_format validation rule is useful when you only accept one known format. Choose thbm/date-parser if its multi-format parsing API reduces custom code in your app.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
frankyso/ipaymu
3mdikram/worldmoneywords
snowsoft/config
itmosoft/laravel-subscriptions
larva/laravel-ai-qwen
adachsoft/api-version-bundle
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core