Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mehedi's avatar

Translate Date Using Carbon

Hi Experts!

I have a little problem about carbon localization. It's perfectly work when I use like


Carbon::setLocale('bn');

Carbon::now()->diffForHumans();

But when I trying this way it will return English

Carbon::setLocale('bn');
Carbon::now()->year
Output: 2017. But I expect ২০১৭.

So how can i get my expected value using carbon localization ????

Regards Mehedi Hasan

2 likes
2 replies
tisuchi's avatar
tisuchi
Best Answer
Level 70

@mehedi

Its not localization. It's called translation.

Localization:

Imagine that you have a post at 3:50 PM in Kuala Lumpur time. If you need to make it localized, it will show at Dhaka 1.50 PM. It's just recalculated your time based on your location. Nothing else.

The things you are expecting that is called Translation. In order to implement that, I prefer you to use any package, that will reduce your stress.

6 likes
mehedi's avatar

Thank you very much to clear about Localization and Translation. @tisuchi

2 likes

Please or to participate in this conversation.