一个将时间转换为阿拉伯时间段的Laravel扩展包。

1.0.3 2024-08-26 14:02 UTC

This package is not auto-updated.

Last update: 2024-09-24 12:54:43 UTC


README

如果你的包不包括用户可以发布的配置文件,您可以从README中删除该部分。以下是更新后的版本

阿拉伯时间包

Latest Stable Version Total Downloads License

阿拉伯时间包是一个PHP包,帮助您以阿拉伯格式显示时间。它旨在轻松集成到您的Laravel应用程序中,但也可以用于任何PHP项目。

功能

  • 以阿拉伯语言格式显示时间。
  • 与Laravel的Blade模板轻松集成。
  • 支持不同的时间格式和自定义。

安装

您可以通过Composer安装此包

composer require getarabictimepackage/arabic-time

用法

基本用法

安装包后,您可以直接在PHP代码中使用它以阿拉伯格式显示当前时间

use GetArabicTimePackage\ArabicTime\ArabicTime;

echo ArabicTime::now(); // Displays the current time in Arabic

自定义时间格式化

您也可以根据需要格式化时间

use GetArabicTimePackage\ArabicTime\ArabicTime;

$time = new DateTime('now');
echo ArabicTime::format($time, 'H:i'); // Displays time in Arabic with a custom format

Blade指令(仅限Laravel)

如果您正在使用Laravel,您可以使用提供的Blade指令以简化集成

  1. config/app.php中注册服务提供者(如果未自动发现)

  2. 在Laravel 11中注册服务提供者在bootstrap/providers.php

    'providers' => [
        // Other service providers...
        GetArabicTimePackage\ArabicTime\ArabicTimeServiceProvider::class,
    ],
  3. 在Blade视图中使用指令

    @arabicTime($time) // Converts the given DateTime instance to Arabic time

Blade示例

<!DOCTYPE html>
<html lang="ar">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Arabic Time Example</title>
</head>
<body>
    <h1>الوقت الحالي: @arabicTime(now())</h1>
</body>
</html>

贡献

欢迎贡献!请提交拉取请求或打开一个问题来讨论您的想法。

许可证

此包是开源软件,根据MIT许可证许可。