Download the PHP package meysampg/intldate without Composer

On this page you can find all versions of the php package meysampg/intldate. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package intldate

Intl. Date

🟥⚠️ THIS PACKAGE IS ABANDONED. PLEASE USE https://github.com/mahdyar/intldate OR FORK THIS REPOSITORY AND MAINTENANCE IT FOR YOURSELF ⚠️🟥

StyleCI Build Status Total Downloads Latest Stable Version Maintainability Test Coverage FOSSA Status

PHP Library for Converting Date to Multiple Calendars

Installation

The preferred way to install this extension is through composer.

Either run

or add

to the require section of your composer.json file.

Also easily you can Download and use it.

Usage

Once the library is installed, simply use it in your php file:

and use it on your desired class:

Anathomy

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.

Conversion

At first I must note that incoming date must be an array in this form:

Currently, 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 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. 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:

It's better to use their handler in code instead of using direct name. These handlers are:

ShortHands

There 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.

Incoming Outgoing
fromPersian toPersian
fromJapanese toJapanese
fromBuddhist toBuddhist
fromChinese toChinese
fromIndian toIndian
fromIslamic toIslamic
fromHebrew toHebrew
fromCoptic toCoptic
fromEthiopic toEthiopic
fromGregorian toGregorian

Showing Date

There are two functions for showing converted dates. The first is asDateTime and the last one is asTimestamp.

Signature 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. Also it's good idea for implementing a function that parse traditional php date-acceptable format (See ToDo section).

asTimestamp function return the unix epoch, positive integer for time after that and negative integer for before that.

Examples

There are some examples for using IntlDateTrait. I think they are necessary and sufficent.

IntlDateTrait API

There 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.

Setters Gettes
setOriginDate($datetimeArray) getFinalDate()
setFromLocale($locale) getFromLocale()
setFromCalendar($calendar) getFromCalendar()
setToLocale($locale) getToLocale()
setToCalendar($calendar) getToCalendar()
getFromLocaleAndCalendar() getToLocaleAndCalendar()
setOriginTimeZone($timezone) getOriginTimeZone()
setFinalTimeZone($timezone) getFinalTimeZone()
setOriginCalendar($locale) getOriginCalendar()
setFinalCalendar($locale) getFinalCalendar()
setFinalDateType($datetype) getFinalDateType()
setFinalTimeType($timetype) getFinalTimeType()
setFinalCalendarType($calendarType) getFinalCalendarType()
setFinalPattern($pattern) getFinalPattern()
setIntlDateFormatter($locale = "en_US", $datetype = IntlDateFormatter::FULL, $timetype = IntlDateFormatter::FULL, $timezone = 'UTC', $calendar = IntlDateFormatter::GREGORIAN, $pattern = 'yyyy/MM/dd HH:mm:ss') getIntlDateFormatter()
setIntlCalendar($timezone = 'Asia/Tehran', $locale = 'fa_IR@calendar=persian') getIntlCalendar()

ToDo

License

FOSSA Status


All versions of intldate with dependencies

PHP Build Version
Package Version
Requires ext-intl Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package meysampg/intldate contains the following files

Loading the files please wait ....