Level 55
@anand_aks try this
if ($hours != 0) {
$time = $hours . __('hour');
}
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
This is a sample code
@php
$totaltime = $totaltime + $deliverylocation->delivery_time;
$hours = intdiv($totaltime, 60);
$time = '';
if ($hours != 0) {
$time = $hours.'hour';
}
@endphp
<input type="hidden" id="delivery_time" value="{{$time}}">
In the above code, I am attaching the string "hour" with the variable $hour. But for adding localization I added "hour" to localization file along with the other language.
But how can i access that here
i tried
if ($hours != 0) {
$time = $hours.{{__('hour')}};
}
But it is showing error.
@anand_aks try this
if ($hours != 0) {
$time = $hours . __('hour');
}
Please or to participate in this conversation.