webrium/pdate

Webrium 波斯日期

1.0.0 2024-05-03 21:34 UTC

This package is not auto-updated.

Last update: 2024-10-03 10:47:47 UTC


README

pdate 提供了使用希吉拉历日期的能力,并可以轻松地将公历日期转换为希吉拉历日期,反之亦然。

希吉拉历日历库是基于 jdf 库创建的

安装 pdate

composer require webrium/pdate
use PDate\PDate;


PDate::new()->get();
// 1403-02-10 21-10-25

PDate::new()
   ->timestamp('1714390128')
   ->format('Y-m-d')
   ->get();
   // 1403-02-10

转换日期

PDate::new()
   ->fromGregorian('2024-04-29')
   ->format('Y-m-d')
   ->get();
  // 1403-02-10


PDate::new()
   ->fromShamsi('1403-02-10')
   ->format('Y-m-d')
   ->getGregorian();
  // 2024-04-29

向日期添加天数、周数和月份

PDate::new()->now()->addDay(4)->get();
// 1403-02-14 21-10-25

PDate::new()->now()->addWeek(1)->get();
// 1403-03-17 21-16-25

PDate::new()->now()->addMonth(1)->get();
// 1403-03-14 21-16-25

PDate::new()
   ->fromGregorian('2024-04-29')
   ->format('Y-m-d')
    ->addDay(5)
   ->get();
  // 1403-02-15

方法

$pdate = PDate::new();

$pdate->day(); // 27

$pdate->month(); // 11

$pdate->year(); // 1403

$pdate->clock(); // 20:46:32

$pdate->hour(); // 23

$pdate->minutes(); // 59

$pdate->second(); // 45

// Persian month name
$pdate->monthName(); //خرداد

//The number of days in the month
$pdate->monthDays(); // 31