定制 agashe/arabic-date 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

agashe/arabic-date

Composer 安装命令:

composer require agashe/arabic-date

包简介

Handle hijri/gregorian calendar in both arabic and english.

README 文档

README

A PHP Package to handle hijri/gregorian calendar in both arabic and english

Features

  • Hijri/Gregorian calendars.
  • Support both arabic/english.
  • Very lightwieght , 0 dependencies.
  • Easy to use , set few options and run.

Installation

composer require agashe/arabic-date

Documentation

ArabicDate hijri converter depends on Kuwati Algorithm , in it's core a single class with few setters/gettes to configure your result.

After installation is done , include the class in your project by:

  • including vendor/autoload.php for Native PHP projects
  • or adding the class to your framework config , for example app/config/app.php for laravel ,

This table demonstrate the basic three setters , we use to initialize ArabicDate

Method Parameter Options Description
setCalendar string 'hijri', 'gregorian' Select the calendar
setLanguage string 'arabic', 'english' Select the language
setFormat string Check the table below Select the date format pattern

ArabicDate uses the default PHP date format characters , this table shows all supported characters in hijri calendar. (for gregorian calendar , all characters work normally !!)

Format character Description
d Day of the month, 2 digits with leading zeros
D A textual representation of a day
j Day of the month without leading zeros
m Numeric representation of a month, with leading zeros
M A textual representation of a month
n Numeric representation of a month, without leading zeros
y A two digit representation of a year
Y A full numeric representation of a year, 4 digits
h 12-hour format of an hour with leading zeros
H 24-hour format of an hour with leading zeros
i Minutes with leading zeros
s Seconds with leading zeros
a/A AM/PM , but in arabic there's no lowercase and uppercase
so they both are the same!

This is the basic example for using ArabicDate

<?php

include "vendor/autoload.php";

use ArabicDate\ArabicDate;

$date = new ArabicDate();

$date->setCalendar('hijri');
$date->setLanguage('english');
$date->setFormat('Y-m-d');

echo $date->get();

// and also you can use the constructor
$date = new ArabicDate('y M D h:i:s a', 'arabic', 'gregorian');
echo $date->get();

Examples


// 1. hijri date in arabic
$date = new ArabicDate('Y/m/d هـ', 'arabic', 'hijri');
echo $date->get(); // ١٤٤٢/٠٩/١٢ هـ

// 2. hijri date in arabic with time
$date = new ArabicDate('Y-m-d h:i:s a', 'arabic', 'hijri');
echo $date->get(); // ١٤٤٢-٠٩-١٢ ٠٢:٢٢:٥٤ مساءً

// 3. gregorian date in arabic
$date = new ArabicDate('y M D h:i:s a', 'arabic', 'gregorian');
echo $date->get(); // ٢١ أبريل السبت ٠٢:١٩:٢٢ مساءً

// 4. hijri date in english with time
$date = new ArabicDate();

$date->setCalendar('hijri');
$date->setLanguage('english');
$date->setFormat('Y-m-d h:i:s a');

echo $date->get(); // 1442-09-12 02:26:10 Masa

License

(ArabicDate) released under the terms of the MIT license.

统计信息

  • 总下载量: 17
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-04-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固