{"id":19458882,"url":"https://github.com/leafsphp/date","last_synced_at":"2025-04-25T06:30:37.357Z","repository":{"id":45197548,"uuid":"408152072","full_name":"leafsphp/date","owner":"leafsphp","description":"📅 Leaf PHP date/time module","archived":false,"fork":false,"pushed_at":"2025-03-31T13:10:11.000Z","size":62,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"v4.x","last_synced_at":"2025-04-13T04:29:39.890Z","etag":null,"topics":["date","leafphp","php"],"latest_commit_sha":null,"homepage":"https://leafphp.dev/docs/utils/date.html","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leafsphp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null},"funding":{"open_collective":"leaf","github":"leafsphp"}},"created_at":"2021-09-19T14:40:54.000Z","updated_at":"2025-04-01T09:00:02.000Z","dependencies_parsed_at":"2022-09-02T12:00:21.196Z","dependency_job_id":"eea3907d-be7c-4ee2-9843-2ce77fb4d0b3","html_url":"https://github.com/leafsphp/date","commit_stats":{"total_commits":37,"total_committers":3,"mean_commits":"12.333333333333334","dds":0.05405405405405406,"last_synced_commit":"ba85333fd07348f1e06b775d226ec23c991e8285"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leafsphp%2Fdate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leafsphp%2Fdate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leafsphp%2Fdate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leafsphp%2Fdate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leafsphp","download_url":"https://codeload.github.com/leafsphp/date/tar.gz/refs/heads/v4.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248989437,"owners_count":21194586,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["date","leafphp","php"],"created_at":"2024-11-10T17:28:50.868Z","updated_at":"2025-04-25T06:30:37.352Z","avatar_url":"https://github.com/leafsphp.png","language":"PHP","readme":"\u003c!-- markdownlint-disable no-inline-html --\u003e\n\u003cp align=\"center\"\u003e\n  \u003cbr\u003e\n  \u003cimg src=\"https://leafphp.dev/logo-circle.png\" height=\"120\"/\u003e\n  \u003cbr\u003e\n\u003c/p\u003e\n\n\u003ch1 align=\"center\"\u003e⏰ Tick\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cb\u003eA powerful, elegant date/time manipulation library for PHP with a familiar JavaScript-like API\u003c/b\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\t\u003ca href=\"https://packagist.org/packages/leafs/date\"\u003e\u003cimg src=\"https://poser.pugx.org/leafs/date/v/stable\" alt=\"Latest Stable Version\"/\u003e\u003c/a\u003e\n\t\u003ca href=\"https://packagist.org/packages/leafs/date\"\u003e\u003cimg src=\"https://poser.pugx.org/leafs/date/downloads\" alt=\"Total Downloads\"/\u003e\u003c/a\u003e\n\t\u003ca href=\"https://packagist.org/packages/leafs/date\"\u003e\u003cimg src=\"https://poser.pugx.org/leafs/date/license\" alt=\"License\"/\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003c!-- \u003cp align=\"center\"\u003e\n  \u003ca href=\"#installation\"\u003eInstallation\u003c/a\u003e •\n  \u003ca href=\"#quick-start\"\u003eQuick Start\u003c/a\u003e •\n  \u003ca href=\"#features\"\u003eFeatures\u003c/a\u003e •\n  \u003ca href=\"#api-reference\"\u003eAPI Reference\u003c/a\u003e •\n  \u003c!-- \u003ca href=\"#examples\"\u003eExamples\u003c/a\u003e •\n\u003c/p\u003e --\u003e\n\u003cbr\u003e\n\n## 🌟 Why Tick?\n\n**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.\n\n```php\n// Get current date in a specific format\necho tick()-\u003eformat('MMMM Do, YYYY'); // March 31st, 2025\n\n// Chain methods for complex operations\n$nextFriday = tick()-\u003eadd(1, 'week')-\u003estartOf('week')-\u003eadd(4, 'day');\necho $nextFriday-\u003eformat('dddd, MMMM D'); // Friday, April 11\n```\n\n## 🚀 Installation\n\n**Using [Leaf CLI](https://cli.leafphp.dev) (Recommended)**:\n\n```bash\nleaf install date\n```\n\n**Using [Composer](https://getcomposer.org/)**:\n\n```bash\ncomposer require leafs/date\n```\n\n## 🏁 Quick Start\n\n```php\n// Current date and time\necho tick()-\u003enow(); // 2025-03-31T12:29:29+00:00\n\n// Parse a specific date\n$birthday = tick('1990-05-15');\necho $birthday-\u003eformat('MMMM D, YYYY'); // May 15, 1990\n\n// Manipulate dates\n$futureDate = tick()-\u003eadd(3, 'months')-\u003esubtract(2, 'days');\necho $futureDate-\u003eformat('YYYY-MM-DD'); // 2025-06-29\n```\n\n## ✨ Features\n\n- **🔄 Familiar API** - If you know Day.js or Moment.js, you already know Tick\n- **🪶 Lightweight** - No heavy dependencies, just pure PHP goodness\n- **🔌 Native Integration** - Seamless integration with PHP's DateTime objects\n- **🌐 Timezone Support** - Work with dates across different timezones effortlessly\n- **📊 Date Comparison** - Easily compare dates with intuitive methods\n- **🧩 Extensible** - Add your own custom functionality when needed\n- **🔍 Validation** - Validate dates with built-in methods\n- **📝 Formatting** - Format dates in any way you need\n\n## 📚 API Reference\n\n### Creating Dates\n\n```php\n// Current date and time\ntick();\ntick()-\u003enow();\n\n// From string\ntick('2025-03-31');\ntick('2025/03/31');\ntick('March 31, 2025');\n\n// From DateTime\ntick(new DateTime('2025-03-31'));\n\n// From tick object\n$tomorrow = tick('2025-03-31')-\u003eadd(1, 'day');\ntick($tomorrow);\n```\n\n### Formatting\n\n```php\n$date = tick('2025-03-31');\n\n// Standard formats\n$date-\u003eformat('YYYY-MM-DD');          // 2025-03-31\n$date-\u003eformat('MMMM D, YYYY');        // March 31, 2025\n$date-\u003eformat('ddd, MMM D, YYYY');    // Mon, Mar 31, 2025\n$date-\u003eformat('YYYY-MM-DD HH:mm:ss'); // 2025-03-31 12:29:29\n\n// Predefined formats\n$date-\u003etoDateString();                // 2025-03-31\n$date-\u003etoTimeString();                // 12:29:29\n$date-\u003etoDateTimeString();            // 2025-03-31 12:29:29\n$date-\u003etoISOString();                 // 2025-03-31T12:29:29.000Z\n```\n\n### Manipulating Dates\n\n```php\n$date = tick('2025-03-31');\n\n// Add time\n$date-\u003eadd(1, 'day');     // 2025-04-01\n$date-\u003eadd(2, 'months');  // 2025-05-31\n$date-\u003eadd(1, 'year');    // 2026-03-31\n\n// Subtract time\n$date-\u003esubtract(1, 'week');  // 2025-03-24\n$date-\u003esubtract(3, 'hours'); // 2025-03-31 09:29:29\n\n// Start/End of time units\n$date-\u003estartOf('month');    // 2025-03-01 00:00:00\n$date-\u003eendOf('year');       // 2025-12-31 23:59:59.999999\n$date-\u003estartOf('day');      // 2025-03-31 00:00:00\n```\n\n### Comparing Dates\n\n```php\n$date = tick('2025-03-31');\n\n$date-\u003eisBefore('2025-04-01');        // true\n$date-\u003eisAfter('2025-03-30');         // true\n$date-\u003eisSame('2025-03-31');          // true\n$date-\u003eisBetween('2025-03-30', '2025-04-01'); // true\n```\n\n\u003c!-- ## 🧪 Examples\n\n### Working with Relative Dates\n\n```php\n// Get tomorrow's date\n$tomorrow = tick()-\u003eadd(1, 'day');\n\n// Get the first day of next month\n$nextMonth = tick()-\u003eadd(1, 'month')-\u003estartOf('month');\n\n// Get last day of current month\n$lastDay = tick()-\u003eendOf('month');\n\n// Check if a date is on a weekend\n$isWeekend = tick('2025-04-05')-\u003eday() === 0 || tick('2025-04-05')-\u003eday() === 6;\n``` --\u003e\n\n\u003c!-- ### Date Calculations\n\n```php\n// Calculate age\n$birthdate = tick('1990-05-15');\n$age = tick()-\u003ediff($birthdate, 'years');\n\n// Calculate days until an event\n$christmas = tick('2025-12-25');\n$daysUntilChristmas = $christmas-\u003ediff(tick(), 'days');\n\n// Calculate business days between dates\n$workDays = tick('2025-04-01')-\u003ediffBusinessDays(tick('2025-04-30'));\n``` --\u003e\n\n### Working with Timezones\n\n```php\n// Create a date in a specific timezone\n$tokyoTime = tick('2025-03-31', 'Asia/Tokyo');\n\n// Convert between timezones\n$newYorkTime = $tokyoTime-\u003esetTimezone('America/New_York');\n```\n\u003c!-- \n// Get timezone offset\n$offset = tick()-\u003egetTimezoneOffset(); // in minutes --\u003e\n\n## 🤝 Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add some amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\n---\n\n\u003cp align=\"center\"\u003e\n  Made with ❤️ by \u003ca href=\"https://leafphp.dev\"\u003eLeaf PHP\u003c/a\u003e\n\u003c/p\u003e\n","funding_links":["https://opencollective.com/leaf","https://github.com/sponsors/leafsphp"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleafsphp%2Fdate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleafsphp%2Fdate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleafsphp%2Fdate/lists"}