Last active
January 9, 2017 10:36
-
-
Save hariadi/81780477001f498ada2a6f7ec928af33 to your computer and use it in GitHub Desktop.
Islamic date using pure PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Requirement: PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0 | |
* Ubuntu: | |
* apt-get install php5-intl | |
* | |
* RedHat: | |
* yum install libicu libicu-devel.x86_64 | |
*/ | |
// full date | |
$DateTime = new DateTime(); | |
$date = new IntlDateFormatter( | |
'ms_MY@calendar=islamic', | |
IntlDateFormatter::FULL, | |
IntlDateFormatter::FULL, | |
'Asia/Kuala_Lumpur', | |
IntlDateFormatter::TRADITIONAL, | |
); | |
echo $date->format($DateTime); | |
echo $date->getPattern(); | |
// custom format | |
$DateTime = new DateTime(); | |
$date = new IntlDateFormatter( | |
'ms_MY@calendar=islamic', | |
IntlDateFormatter::FULL, | |
IntlDateFormatter::FULL, | |
'Asia/Kuala_Lumpur', | |
IntlDateFormatter::TRADITIONAL, | |
'd MMMM y' | |
); | |
echo $date->format($DateTime); | |
echo $date->getPattern(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment