PHP code example of hanifhefaz / dcter

1. Go to this page and download the library: Download hanifhefaz/dcter 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/ */

    

hanifhefaz / dcter example snippets



use HanifHefaz\Dcter\Dcter;

$date = "1401-01-16";
    $gregorianDate = Dcter::JalaliToGregorian($date);
    return $gregorianDate; // returns 2022-04-05


use HanifHefaz\Dcter\Dcter;

$date = "2023-04-08";
    $jalaliDate = Dcter::GregorianToJalali($date);
    return $jalaliDate; // returns 1402-01-19


use HanifHefaz\Dcter\Dcter;

$date = "2023-04-08";
    $hijriDate = Dcter::GregorianToHijri($date);
    return $hijriDate; // returns 1444-09-17


use HanifHefaz\Dcter\Dcter;

$date = "1444-09-17";
    $gregorianDate = Dcter::HijriToGregorian($date);
    return $gregorianDate; // returns 2023-04-08


use HanifHefaz\Dcter\Dcter;

$date = "1444-09-17";
    $julianDate = Dcter::HijriToJulian($date);
    return $julianDate; // returns 2460043


use HanifHefaz\Dcter\Dcter;

$date = "2460043";
    $hijriDate = Dcter::JulianToHijri($date);
    return $hijriDate; // returns 1444-09-17


use HanifHefaz\Dcter\Dcter;

$date = "1444-09-23";
    $hijriDate = Dcter::HijriToJalali($date);
    return $hijriDate; // returns 1402-01-25


use HanifHefaz\Dcter\Dcter;

$date = "1402-01-25";
    $hijriDate = Dcter::JalaliToHijri($date);
    return $hijriDate; // returns 1444-09-23


use HanifHefaz\Dcter\Dcter;

$date = "1402-01-25";
    $carbonDate = Dcter::Carbonize($date);
    return $carbonDate; // returns 1402-01-25 00:00:00