PHP code example of mr.incognito / date-converter

1. Go to this page and download the library: Download mr.incognito/date-converter 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/ */

    

mr.incognito / date-converter example snippets



$engDate = '2025-03-12';

$npDate = '2081-11-28';

$currentBsDate = DateConverter::currentBsDate('m-d-Y');;
// Result: '11-28-2081'

$currentBsDateDetailInArray = DateConverter::currentBsDateDetail();
// Result: [  "year" => 2081
              "month" => 11
              "day" => 28
              "week_day" => "बुधवार"
              "month_name" => "फाल्गुण"
              "num_week_day" => 4 ]

$currentAdDate = DateConverter::currentAdDate('m/d/Y');;
// Result: '03/12/2025'

$currentAdDateDetailInArray = DateConverter::currentAdDateDetail();
// Result: [  "year" => 2025
              "month" => 3
              "day" => 12
              "week_day" => "Wednesday"
              "month_name" => "Mar"
              "num_week_day" => 3 ]

$dateFromAdTBS = DateConverter::fromAdToBs('2025-3-12', 'm/d/Y');
// Result: '11/28/2081'

$dateFromBsToAd = DateConverter::fromBsToAd('2081-11-28', 'm-d-Y');
// Result: '03-12-2025'

// month can be NepaliMonthEnum::XXX->value or month number (1-12)

$totalDaysInNepaliMonth = DateConverter::totalDaysInNepaliMonth(2081, NepaliMonthEnum::FALGUN->value);
// Result: 29 

$startAndEndAdDateFromNepaliYear = DateConverter::startAndEndAdDateFromNepaliYear(2081, 'm-d-Y');
// Result: [
  "start_date" => "04-13-2024"
  "end_date" => "04-13-2025"
]

$startAndEndAdDateFromNepaliMonth = DateConverter::startAndEndAdDateFromNepaliMonth(2081, NepaliMonthEnum::FALGUN->value,'m-d-Y');
// Result: [
  "start_date" => "02-13-2025"
  "end_date" => "03-13-2025"
]

$totalDaysInBsYear = DateConverter::daysInBsYear(2080);
// Result: 365 
    
$totalDaysInADYear = DateConverter::daysInAdYear(2024);
// Result: 366