24h date format with no space preceding individual digits

I have the following

$nextDisponibility->formatLocalized('%A %e %B à %kh%M')

which gives me

lundi 13 novembre à 8h00

How could I remove the space before the number in one hour?

From php doc :

% k Hour in 24-hour format with a space preceding single digits from 0 to 23

Is the preg_replace('!\s+!', ' ', $nextDisponibility->formatLocalized('%A %e %B à %kh%M'));best way to do this?

+4
source share
1 answer

If you don't want to perform string manipulations, you can probably do something more "hacked":

$string = $nextDisponibility->formatLocalized('%A ')
.trim($nextDisponibility->formatLocalized("%e"))
.$nextDisponibility->formatLocalized(" %B ")
.ltrim($nextDisponibility->formatLocalized("%kh%M"));

However $string = str_replace(' ',' ',$nextDisponibility->formatLocalized('%A %e %B à %kh%M')), it is probably better if you do not need other double spaces.

+1
source

Source: https://habr.com/ru/post/1688858/


All Articles