{"id":37235231,"url":"https://github.com/meysampg/intldate","last_synced_at":"2026-01-15T04:01:07.226Z","repository":{"id":48622406,"uuid":"67480531","full_name":"meysampg/intldate","owner":"meysampg","description":"A small php library for date converting between multiple calendar","archived":true,"fork":false,"pushed_at":"2021-07-17T12:35:59.000Z","size":64,"stargazers_count":21,"open_issues_count":0,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-24T03:43:04.549Z","etag":null,"topics":["calendar","convert-dates","date","i18n","international","php-library","region"],"latest_commit_sha":null,"homepage":"http://pourganji.ir/intldate","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/meysampg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-06T06:37:45.000Z","updated_at":"2025-08-14T17:47:16.000Z","dependencies_parsed_at":"2022-09-15T21:02:53.614Z","dependency_job_id":null,"html_url":"https://github.com/meysampg/intldate","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/meysampg/intldate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meysampg%2Fintldate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meysampg%2Fintldate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meysampg%2Fintldate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meysampg%2Fintldate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/meysampg","download_url":"https://codeload.github.com/meysampg/intldate/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meysampg%2Fintldate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28419962,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T10:47:48.104Z","status":"ssl_error","status_checked_at":"2026-01-14T10:46:19.031Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["calendar","convert-dates","date","i18n","international","php-library","region"],"created_at":"2026-01-15T04:01:06.722Z","updated_at":"2026-01-15T04:01:07.186Z","avatar_url":"https://github.com/meysampg.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Intl. Date\n==========\n🟥⚠️ _THIS PACKAGE IS ABANDONED. PLEASE USE https://github.com/mahdyar/intldate OR FORK THIS REPOSITORY AND MAINTENANCE IT FOR YOURSELF_ ⚠️🟥\n\n[![StyleCI](https://styleci.io/repos/67480531/shield?branch=master)](https://styleci.io/repos/67480531) [![Build Status](https://travis-ci.org/meysampg/intldate.svg?branch=master)](https://travis-ci.org/meysampg/intldate) [![Total Downloads](https://poser.pugx.org/meysampg/intldate/downloads)](https://packagist.org/packages/meysampg/intldate) [![Latest Stable Version](https://poser.pugx.org/meysampg/intldate/v/stable)](https://packagist.org/packages/meysampg/intldate) [![Maintainability](https://api.codeclimate.com/v1/badges/a8958ec9f4ffc059b6fb/maintainability)](https://codeclimate.com/github/meysampg/intldate/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/a8958ec9f4ffc059b6fb/test_coverage)](https://codeclimate.com/github/meysampg/intldate/test_coverage)\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fmeysampg%2Fintldate.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fmeysampg%2Fintldate?ref=badge_shield)\n\nPHP Library for Converting Date to Multiple Calendars\n\nInstallation\n------------\n\nThe preferred way to install this extension is through [composer](http://getcomposer.org/download/).\n\nEither run\n\n```bash\ncomposer require --prefer-dist meysampg/intldate \"*\"\n```\n\nor add\n\n```json\n\"meysampg/intldate\": \"*\"\n```\n\nto the require section of your `composer.json` file.\n\nAlso easily you can [Download](https://github.com/meysampg/intldate/archive/master.zip) and use it.\n\nUsage\n-----\n\nOnce the library is installed, simply use it in your php file:\n\n```php\nuse meysampg\\intldate\\IntlDateTrait;\n```\nand use it on your desired class:\n\n```php\n\u003c?php\n\nnamespace foo\\bar;\n\nuse meysampg\\intldate\\IntlDateTrait;\n\nclass Bar\n{\n  use IntlDateTrait;\n  // Some codes are here!\n \n  echo $this-\u003efromGregorian([2017, 9, 7, 12, 23, 45])-\u003etoPersian('en')-\u003easDateTime();\n}\n```\n\nAnathomy\n--------\n\n`IntlDateTrait` has a simple logic for naming methods: \"A date starts from *origin* and ends to *final*. So all methods (setters and getters) that are related to incoming date are named by `setOriginXXXX` and `getOriginXXXX` (which `XXXX` shows a feature of time, like *timezone* or *locale*) and all methods that are corresponded to outgoing date are regarded as `setFinalXXXX` and `getFinalXXXX`. A list of available methods can be find in bottom of this document.\n\nConversion\n----------\nAt first I must note that incoming date must be an array in this form:\n\n```php\n[\n    year, // 2016\n    month, // 2\n    day, // 23\n    hour, // 12\n    minute, // 23\n    second // 4\n]\n```\nCurrently, the library **CAN'T** parse a string as time (See ToDo section), so before converting a date, you **MUST** parse it on a acceptable array (It can be done with `preg_match` or each tools that you know). Now you can easily use\n`IntlDateTrait::from($datetimeArray, $locale, $calendar)` for importing an incoming date and `IntlDateTrait::to($locale, $calendar)` for converting it to another system. We disccuesed about `$datetimeArray` in the first of this section, it's our date for converting on a accepted format. `$locale` is the regional information of a language. For example for The *English* it's `en`, for *Farsi* it's `fa`, for *Spanish* it's `es` and so on. You can find a complete list of them at [this link](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes). And finally calendar is your desired date system. This library use the `Intl*` family of `php` and so you can use all supported calendar in `ICU` project. Now this calendars are supported:\n - persian\n - gregorian\n - japanese\n - buddhist\n - chinese\n - indian\n - islamic\n - hebrew\n - coptic\n - ethiopic\n\nIt's better to use their handler in code instead of using direct name. These handlers are:\n\n```php\n// Use them in `self::$CAL_CALENDAR, for example `$calendar = self::$CAL_HEBREW`.\n$CAL_PERSIAN\n$CAL_JAPANESE\n$CAL_BUDDHIST\n$CAL_CHINESE\n$CAL_INDIAN\n$CAL_ISLAMIC\n$CAL_HEBREW\n$CAL_COPTIC\n$CAL_ETHIOPIC\n$CAL_GREGORIAN\n```\n\nShortHands\n----------\nThere are some shorthands for converting dates in a painless way (Yeah! With all of my proud, I'm a **Lazy** man :D). This shorthands are formatted as `fromYyyy()` for incoming date function and `toZzzz()` for outgoing date function such that, `Yyyy` and `Zzzz` are the name of calendars. For incoming function, the signature is `fromYyyy($datetimeArray, $locale = 'en_US', $timezone = 'UTC)` and for outgoing is `toZzzz($locale = 'fa', $timezone = 'UTC')`. Use `$locale` in incoming function if you have non-latin digits and use it on outgoing function, if you wanna show the converted date by latin digits (Based on region of calendar, `$locales` are defined, for example the default locate of `Persian` calendar for outgoing function is `fa`). Also with changing `$timezone` in both `fromYyyy` and `ToZzzz` functions, you can convert a datetime from one to another. Shorthands are listed in table.\n\n|   Incoming    |   Outgoing    |\n|---------------|---------------|\n|fromPersian    |   toPersian   |\n|fromJapanese   |toJapanese     |\n|fromBuddhist   |toBuddhist     |\n|fromChinese    |toChinese      |\n|fromIndian     |toIndian       |\n|fromIslamic    |toIslamic      |\n|fromHebrew     |toHebrew       |\n|fromCoptic     |toCoptic       |\n|fromEthiopic   |toEthiopic     |\n|fromGregorian  |toGregorian    |\n\nShowing Date\n------------\nThere are two functions for showing converted dates. The first is `asDateTime` and the last one is `asTimestamp`.\n\nSignature of `asDateTime` is `asDateTime($pattern = 'yyyy/MM/dd, HH:mm:ss')`. This function accepts an `ICU`-acceptable format. You can find more info from [this link](http://www.icu-project.org/apiref/icu4c/classSimpleDateFormat.html#details). Also it's good idea for implementing a function that parse traditional php `date`-acceptable format (See ToDo section).\n\n`asTimestamp` function return the unix epoch, positive integer for time after that and negative integer for before that.\n\nExamples\n--------\nThere are some examples for using `IntlDateTrait`. I think they are necessary and sufficent.\n\n```php\n$this-\u003efromTimestamp(1504770825)-\u003etoPersian('en')-\u003easDateTime();\n// '1396/06/16, 07:53:45'\n\n$this-\u003efromGregorian([2017, 9, 7, 12, 23, 45])-\u003etoPersian('en')-\u003easDateTime();\n// '1396/06/16, 07:53:45'\n\n$this-\u003efromGregorian([2017, 9, 7, 12, 23, 45])-\u003etoPersian()-\u003easDateTime();\n// '۱۳۹۶/۰۶/۱۶, ۰۷:۵۳:۴۵'\n\n$this-\u003efromGregorian([2017, 9, 7, 12, 23, 45])-\u003etoJapanese()-\u003easDateTime();\n// '0029/09/07, 07:53:45'\n\n$this-\u003efromGregorian([2017, 9, 7, 12, 23, 45])-\u003etoIslamic()-\u003easDateTime();\n// '١٤٣٨/١٢/١٧, ٠٧:٥٣:٤٥'\n\n$this-\u003efromGregorian([2017, 9, 7, 12, 23, 45])-\u003etoBuddhist()-\u003easDateTime();\n// '2560/09/07, 07:53:45'\n\n$this-\u003efromGregorian([2017, 9, 7, 12, 23, 45])-\u003etoChinese()-\u003easDateTime();\n// '0034/07/17, 07:53:45'\n\n$this-\u003efromGregorian([2017, 9, 7, 12, 23, 45])-\u003etoIndian()-\u003easDateTime();\n// '1939/06/16, 07:53:45'\n\n$this-\u003efromGregorian([2017, 9, 7, 12, 23, 45])-\u003etoHebrew()-\u003easDateTime();\n// 'תשע״ז/י״ב/ט״ז, 07:53:45'\n\n$this-\u003efromGregorian([2017, 9, 7, 12, 23, 45])-\u003etoCoptic()-\u003easDateTime();\n// '1733/13/02, 07:53:45'\n\n$this-\u003efromGregorian([2017, 9, 7, 12, 23, 45])-\u003etoEthiopic()-\u003easDateTime();\n// '2009/13/02, 07:53:45'\n\n$this-\u003efromPersian([1396, 6, 16, 12, 23, 45])-\u003etoIslamic()-\u003easDateTime();\n// '١٤٣٨/١٢/١٧, ٠٧:٥٣:٤٥'\n\n$this-\u003efromPersian([1396, 6, 16, 12, 23, 45])-\u003etoGregorian()-\u003easDateTime();\n// '2017/09/07, 07:53:45'\n\n$this-\u003efromPersian([1396, 6, 16, 12, 23, 45])-\u003etoGregorian()-\u003esetFinalTimeZone('Asia/Tehran')-\u003easDateTime();\n// '2017/09/07, 12:23:45'\n\n$this-\u003efromPersian([1396, 6, 16, 12, 23, 45])-\u003etoGregorian()-\u003esetFinalTimeZone('Asia/Tehran')-\u003easDateTime('yyyy');\n// '2017'\n\n$this-\u003efromGregorian([2017, 9, 7, 12, 23, 45])-\u003easTimestamp();\n// '1504770825'\n\n$this-\u003efromPersian([1396, 6, 16, 12, 23, 45])-\u003easTimestamp();\n// '1504770825'\n```\n\nIntlDateTrait API\n-----------------\nThere are some methods that help to control more on converting process. I just list them in this section. I think thier name complain their usages, If it's not, please write document for them :D.\n\n|Setters                         |Gettes                    |\n|--------------------------------|--------------------------|\n|`setOriginDate($datetimeArray)` | `getFinalDate()`         |\n|`setFromLocale($locale)`        |`getFromLocale()`         |\n|`setFromCalendar($calendar)`    |`getFromCalendar()`       |\n|`setToLocale($locale)`          |`getToLocale()`           |\n|`setToCalendar($calendar)`      |`getToCalendar()`         |\n|`getFromLocaleAndCalendar()`    |`getToLocaleAndCalendar()`|\n|`setOriginTimeZone($timezone)`  |`getOriginTimeZone()`     |\n|`setFinalTimeZone($timezone)`   |`getFinalTimeZone()`      |\n|`setOriginCalendar($locale)`    |`getOriginCalendar()`     |\n|`setFinalCalendar($locale)`     |`getFinalCalendar()`      |\n|`setFinalDateType($datetype)`   |`getFinalDateType()`      |\n|`setFinalTimeType($timetype)`   |`getFinalTimeType()`      |\n|`setFinalCalendarType($calendarType)`|`getFinalCalendarType()`|\n|`setFinalPattern($pattern)`     |`getFinalPattern()`       |\n|`setIntlDateFormatter($locale = \"en_US\", $datetype = IntlDateFormatter::FULL, $timetype = IntlDateFormatter::FULL, $timezone = 'UTC', $calendar = IntlDateFormatter::GREGORIAN, $pattern = 'yyyy/MM/dd HH:mm:ss')`|`getIntlDateFormatter()`|\n|`setIntlCalendar($timezone = 'Asia/Tehran', $locale = 'fa_IR@calendar=persian')`|`getIntlCalendar()`|\n\nToDo\n----\n - Implement `parsePattern($pattern)` method.\n\n ```php\n/**\n * Implement a function to parse both ICU patterns and php date\n * function patterns and return a pattern that is compatible on\n * ICU format. The php pattern must start with php keyword, for\n * example `php:Y-F-d, H:i:s` is a php pattern.\n */\n ```\n\n - ~~Implement `guessDateTime($timestring)` method.~~\n \n - ~~Write tests!~~\n \n Contribute\n ----------\n Just fork this repository, do your modification or addition and send a pull request!\n\n\n## License\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fmeysampg%2Fintldate.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fmeysampg%2Fintldate?ref=badge_large)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeysampg%2Fintldate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmeysampg%2Fintldate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeysampg%2Fintldate/lists"}