我的日期值如下所示: 2021-10-09
我想將格式更改為:(9/10跳過年份,0在數字之前跳過并更改-為/
$date = strtotime('2021-10-09');
$new_date = date('d-m', $date);
$new_date = str_replace('-','/',$new_date);
$new_date = str_replace('0','',$new_date);
echo $new_date // result: 9/1 (should be 9/10)
所以我需要找到一種方法:如果0在另一個數字后面,那么不要跳過0
我怎樣才能做到這一點?
uj5u.com熱心網友回復:
使用 date('j/n', $date) 并洗掉 str_replace 行。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/362352.html
