[英]Date format 24h without a space preceding single digits
I have the following 我有以下
$nextDisponibility->formatLocalized('%A %e %B à %kh%M')
which gives me 这给了我
lundi 13 novembre à 8h00 lundi 11月13日à8h00
How could I remove the space before the single hour digit ? 如何删除一个小时数字前的空格?
%k Hour in 24-hour format, with a space preceding single digits 0 through 23 %k小时,采用24小时制,空格前加0到23的个位数
Is preg_replace('!\\s+!', ' ', $nextDisponibility->formatLocalized('%A %e %B à %kh%M'));
是preg_replace('!\\s+!', ' ', $nextDisponibility->formatLocalized('%A %e %B à %kh%M'));
the best way to do this ? 最好的方法做到这一点?
If you don't want to do string manipulations you can probably do something more "hacky": 如果您不想执行字符串操作,则可以做更多“ hacky”操作:
$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'))
is probably better if you don't care about other double spaces. 但是$string = str_replace(' ',' ',$nextDisponibility->formatLocalized('%A %e %B à %kh%M'))
如果您不关心其他双$string = str_replace(' ',' ',$nextDisponibility->formatLocalized('%A %e %B à %kh%M'))
可能更好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.