A powerful, elegant date/time manipulation library for PHP with a familiar JavaScript-like API
Latest Stable Version Total Downloads License
Tick is a modern, lightweight PHP date/time library designed to make working with dates and times as painless as possible. If you're familiar with JavaScript libraries like Moment.js or Day.js, you'll feel right at home with Tick.
// Get current date in a specific format echo tick()->format('MMMM Do, YYYY'); // March 31st, 2025 // Chain methods for complex operations $nextFriday = tick()->add(1, 'week')->startOf('week')->add(4, 'day'); echo $nextFriday->format('dddd, MMMM D'); // Friday, April 11
Using Leaf CLI (Recommended):
leaf install date
Using Composer :
composer require leafs/date
// Current date and time echo tick()->now(); // 2025εΉ΄03ζ31ζ₯T12:29:29+00:00 // Parse a specific date $birthday = tick('1990εΉ΄05ζ15ζ₯'); echo $birthday->format('MMMM D, YYYY'); // May 15, 1990 // Manipulate dates $futureDate = tick()->add(3, 'months')->subtract(2, 'days'); echo $futureDate->format('YYYY-MM-DD'); // 2025εΉ΄06ζ29ζ₯
- π Familiar API - If you know Day.js or Moment.js, you already know Tick
- πͺΆ Lightweight - No heavy dependencies, just pure PHP goodness
- π Native Integration - Seamless integration with PHP's DateTime objects
- π Timezone Support - Work with dates across different timezones effortlessly
- π Date Comparison - Easily compare dates with intuitive methods
- π§© Extensible - Add your own custom functionality when needed
- π Validation - Validate dates with built-in methods
- π Formatting - Format dates in any way you need
// Current date and time tick(); tick()->now(); // From string tick('2025εΉ΄03ζ31ζ₯'); tick('2025εΉ΄03ζ31ζ₯'); tick('March 31, 2025'); // From DateTime tick(new DateTime('2025εΉ΄03ζ31ζ₯')); // From tick object $tomorrow = tick('2025εΉ΄03ζ31ζ₯')->add(1, 'day'); tick($tomorrow);
$date = tick('2025εΉ΄03ζ31ζ₯'); // Standard formats $date->format('YYYY-MM-DD'); // 2025εΉ΄03ζ31ζ₯ $date->format('MMMM D, YYYY'); // March 31, 2025 $date->format('ddd, MMM D, YYYY'); // Mon, Mar 31, 2025 $date->format('YYYY-MM-DD HH:mm:ss'); // 2025εΉ΄03ζ31ζ₯ 12:29:29 // Predefined formats $date->toDateString(); // 2025εΉ΄03ζ31ζ₯ $date->toTimeString(); // 12:29:29 $date->toDateTimeString(); // 2025εΉ΄03ζ31ζ₯ 12:29:29 $date->toISOString(); // 2025εΉ΄03ζ31ζ₯T12:29:29.000Z
$date = tick('2025εΉ΄03ζ31ζ₯'); // Add time $date->add(1, 'day'); // 2025εΉ΄04ζ01ζ₯ $date->add(2, 'months'); // 2025εΉ΄05ζ31ζ₯ $date->add(1, 'year'); // 2026εΉ΄03ζ31ζ₯ // Subtract time $date->subtract(1, 'week'); // 2025εΉ΄03ζ24ζ₯ $date->subtract(3, 'hours'); // 2025εΉ΄03ζ31ζ₯ 09:29:29 // Start/End of time units $date->startOf('month'); // 2025εΉ΄03ζ01ζ₯ 00:00:00 $date->endOf('year'); // 2025εΉ΄12ζ31ζ₯ 23:59:59.999999 $date->startOf('day'); // 2025εΉ΄03ζ31ζ₯ 00:00:00
$date = tick('2025εΉ΄03ζ31ζ₯'); $date->isBefore('2025εΉ΄04ζ01ζ₯'); // true $date->isAfter('2025εΉ΄03ζ30ζ₯'); // true $date->isSame('2025εΉ΄03ζ31ζ₯'); // true $date->isBetween('2025εΉ΄03ζ30ζ₯', '2025εΉ΄04ζ01ζ₯'); // true
// Create a date in a specific timezone $tokyoTime = tick('2025εΉ΄03ζ31ζ₯', 'Asia/Tokyo'); // Convert between timezones $newYorkTime = $tokyoTime->setTimezone('America/New_York');
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Made with β€οΈ by Leaf PHP