PHP code example of webrium / pdate

1. Go to this page and download the library: Download webrium/pdate library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

webrium / pdate example snippets


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