A Laravel package to convert time to Arabic time periods.

1.0.3 2024-08-26 14:02 UTC

This package is not auto-updated.

Last update: 2024-09-10 12:28:49 UTC


README

If your package doesn't include a configuration file that users can publish, you can remove that part from the README. Here's the updated version:

Arabic Time Package

Latest Stable Version Total Downloads License

Arabic Time Package is a PHP package that helps you display time in Arabic format. It's designed to be easy to integrate into your Laravel applications, but it can be used in any PHP project.

Features

  • Display time in Arabic language format.
  • Easy integration with Blade templates in Laravel.
  • Supports different time formats and customization.

Installation

You can install the package via Composer:

composer require getarabictimepackage/arabic-time

Usage

Basic Usage

After installing the package, you can use it directly in your PHP code to display the current time in Arabic format:

use GetArabicTimePackage\ArabicTime\ArabicTime;

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

Custom Time Formatting

You can also format the time according to your needs:

use GetArabicTimePackage\ArabicTime\ArabicTime;

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

Blade Directives (Laravel Only)

If you're using Laravel, you can utilize the provided Blade directives for easier integration:

  1. Register the service provider in config/app.php (if not auto-discovered):

  2. Register the service provider in Laravel 11 bootstrap/providers.php

    'providers' => [
        // Other service providers...
        GetArabicTimePackage\ArabicTime\ArabicTimeServiceProvider::class,
    ],
  3. Use the directives in your Blade views:

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

Example in 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>

Contributing

Contributions are welcome! Please submit a pull request or open an issue to discuss your ideas.

License

This package is open-sourced software licensed under the MIT license.