1. Go to this page and download the library: Download rohanadhikari/nepali-date 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/ */
rohanadhikari / nepali-date example snippets
use RohanAdhikari\NepaliDate\NepaliDate;
use RohanAdhikari\NepaliDate\NepaliDateImmutable;
// Current Nepali date and time
$now = NepaliDate::now();
// Parse a natural-language notation and manipulate it
$date = NepaliDate::fromNotation('tomorrow');
$date->addDays(5);
// Convert to Gregorian (AD)
$adDate = $date->toAd();
// Format it
echo $date->format(NepaliDate::FORMAT_DATETIME_24_FULL);
// e.g. 2082-06-30 14:45:22
// Immutable variant — every mutation returns a new instance
$immutableNow = NepaliDateImmutable::now();
$newDate = $immutableNow->addDays(10); // original is unchanged
use RohanAdhikari\NepaliDate\NepaliDate;
$now = NepaliDate::now();
echo $now->format(NepaliDate::FORMAT_DATETIME_24_FULL);
$ad = new DateTime('now', new DateTimeZone('Asia/Kathmandu'));
echo NepaliDate::fromAd($ad)->format(NepaliDate::FORMAT_DATE_YMD);
$date = NepaliDate::now();
$date->setLocale(NepaliDate::NEPALI); // or ->locale('np')
echo $date->format(NepaliDate::FORMAT_DATETIME_24);
// Example Output: २०८२-०६-३१ २१:३४
$date->resetLocale();
use RohanAdhikari\NepaliDate\Laravel\Casts\ADAsNepaliDate;
class Post extends Model
{
protected function casts(): array
{
return ['published_at' => ADAsNepaliDate::class];
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.