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');?>
.
Asked
Active
Viewed 788 times
1

Veger
- 37,240
- 11
- 105
- 116

rupesh-mdr
- 71
- 11
-
5If nothing else helps: https://github.com/amant/Nepali-Date-Convert – Realitätsverlust Jun 03 '14 at 07:45
2 Answers
2
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);
?>

Bas
- 61
- 2
0
Setting the locale in PHP should provide you with the current date/time.
In order to make use of the current locale you need strftime()
instead of date()
:
if(setlocale(LC_TIME, "ne") === false) { // or you can try "ne_NP"
echo "Could not set locale to ne\n";
}
echo strftime("%Y");
(I have not tried this example for the Nepalese locale, as I do not have it readily installed on my system)
On that note: you need to have the required locale installed/available. On a *nix system you can use locale -a
to find all available/installed locales on your system. See List of All Locales and Their Short Codes? for more information on (installing) locales.