aselsan/indonesian-date

印度尼西亚标准日期时间输出

v1.1.1 2024-09-08 14:34 UTC

This package is auto-updated.

Last update: 2024-09-08 14:36:11 UTC


README

为CodeIgniter 4提供的轻量级印度尼西亚标准日期时间输出

CodeIgniter PHP Version Require

快速入门

  1. 使用Composer安装
composer require aselsan/indonesian-date
  1. 设置实体
use Aselsan\IndonesianDate\Traits\IndonesianDateTraits;
use CodeIgniter\Shield\Entities\User as ShieldUserEntity;

class User extends ShieldUserEntity
{
    use IndonesianDateTraits;

    public function __construct(?array $data = null)
    {
        parent::__construct($data);
    }

用法

 /**
   * Default parameters for indonesianDate
   * indonesianDate(string $attribute, bool $showDayOfWeek = true, bool $showTime = false)
   */

  echo auth()->user()->indonesianDate('created_at');
  // Result: "Jum'at, 6 September 2024"

  // If you want to hide the day of the week, set the second parameter to false
  echo auth()->user()->indonesianDate('created_at', false);
  // Result: "6 September 2024"

  // If you want to display the time, set the third parameter to true
  echo auth()->user()->indonesianDate('created_at', false, true);
  // Result: "6 September 2024 18:00"

  // Get zodiac sign
  echo auth()->user()->zodiac('tanggal_lahir');
  // Result: "Aquarius"

  // Get age
  echo auth()->user()->age('tanggal_lahir');
  // Result: 18

许可证

本项目的许可证为MIT许可证 - 请参阅LICENSE文件以获取详细信息。