php-carbon

Carbon locale not respected?

穿精又带淫゛_ 提交于 2020-08-19 16:57:33
问题 In my Laravel 6 app, I have Carbon::now()->locale() returning it as it should be. As confirmation that the locale is loaded, Carbon::now()->monthName correctly outputs febbraio . BUT Carbon::now()->format('F') and Carbon::now()->formatLocalized('%B') both return the english version February . Why does the first function output the correct localized month while the others do not? 回答1: Apparently, formatLocalized() is somehow deprecated or not working as intended. From the Carbon docs: You also

Error with date when upgrading to Laravel 7

守給你的承諾、 提交于 2020-05-15 05:08:18
问题 I have successfully upgraded my Laravel instance to version 7. So far everything seems fine apart from the following error. Argument 1 passed to Carbon\CarbonInterval::setLocalTranslator() must implement interface Symfony\Component\Translation\TranslatorInterface, instance of Carbon\Translator given, called in /var/www/laravel/vendor/nesbot/carbon/src/Carbon/Traits/Difference.php I have followed the upgrade documentation and have added the following to my models (but still having the same

Error with date when upgrading to Laravel 7

丶灬走出姿态 提交于 2020-05-15 05:07:47
问题 I have successfully upgraded my Laravel instance to version 7. So far everything seems fine apart from the following error. Argument 1 passed to Carbon\CarbonInterval::setLocalTranslator() must implement interface Symfony\Component\Translation\TranslatorInterface, instance of Carbon\Translator given, called in /var/www/laravel/vendor/nesbot/carbon/src/Carbon/Traits/Difference.php I have followed the upgrade documentation and have added the following to my models (but still having the same

Laravel Carbon, retrieve today's date with weekday?

青春壹個敷衍的年華 提交于 2020-03-13 07:18:11
问题 I am using carbon to compare 2 dates with today's date, however I also have another field in a database called weekday which contains values like: 'MO' 'TU' 'WE' So I don't only want to search and output by dates but also search by a weekday so: public function show($id) { $today = Carbon::now(); $weekday = //whatever carbon or something else has to retrieve today's day $event = Event::with('businesses') ->where('startdate', '<', $today->format('Y-m-d')) ->where('endate', '>', $today->format(