PHP code example of ashbink / nepali-miti
1. Go to this page and download the library: Download ashbink/nepali-miti 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/ */
ashbink / nepali-miti example snippets
$englishDate = NepDate::toEng('2083-04-25');
/*or*/
$englishDate = nep_to_eng_date('2083-04-25');
$nepaliDate = NepDate::toNep('2026-08-10');
/*or*/
$nepaliDate = eng_to_nep_date('2026-08-10');
// Input is DD/MM/YYYY, output will be default (YYYY-MM-DD)
$englishDate = NepDate::toEng('25/04/2083', 'Y-m-d', 'd/m/Y');
/*or*/
$englishDate = nep_to_eng_date('25/04/2083', 'Y-m-d', 'd/m/Y');
// Input is DD/MM/YYYY, output will be default (YYYY-MM-DD)
$nepaliDate = NepDate::toNep('08/10/2026', 'Y/m/d', 'm/d/Y');
/*or*/
$nepaliDate = eng_to_nep_date('08/10/2026', 'Y/m/d', 'm/d/Y');
// Default Text Format (Y F j)
$nepaliText = NepDate::toNepText('2026-08-10');
/*or*/
$nepaliText = eng_to_nep_text('2026-08-10')
// Custom Text Format (j F Y)
$nepaliTextCustom = NepDate::toNepText('2026-08-10', 'j F Y');
/*or*/
$nepaliTextCustom = eng_to_nep_text('2026-08-10')
// English Text Format
$englishText = NepDate::toEngText('2083-04-25', 'F j, Y');
/*or*/
$englishText = nep_to_eng_text('2083-04-25')
shbink\NepaliDate\NepDate;
class EventManager
{
public function store(string $submittedNepaliDate)
{
$englishDate = NepDate::toEng($submittedNepaliDate);
$todayEnglishDate = date('Y-m-d');
$nepaliDate = NepDate::toNep($todayEnglishDate);
header('Content-Type: application/json');
echo json_encode([
'ad_date' => $englishDate,
'bs_date' => $nepaliDate,
]);
exit;
}
}
$event = new EventManager();
$event->store('2082-04-24');