Search code examples
phplocale

Required to get current nepal year only in php ?? Is there any solution?


I only get the current year i.e 2014 by <?php echo date('Y');?>. But i want a nepal current date 2071.How to get nepal date will u please help me to get nepal current date.Is there any way to get the current nepali year like <?php echo date('y');?>.


Solution

  • You could use Carbon for this: https://github.com/briannesbitt/Carbon

    The formula is: DateToday + 56 years + 8 months + 15 days

    To do this in Carbon:

    <?php
    
    $todaysDateInGregorian = Carbon::now();
    $currentDateInNepal = $todaysDateInGregorian->addYears(56)->addMonths(8)->addDays(15);
    
    ?>