昇順でソートされた日付配列があります。日付を次のように表示したい
Oct 10,12,24 2012
Dec 12,20,24 2012
Jan 02,10,25 2013
10月、12月、1月などの日付と日付と年を取得しましたが、上記の形式で表示したいと考えています。以下のコードを試しましたが、望ましい結果が得られません。誰かがこれを手伝ってくれますか?$CruiseDetailsSailing は、日付を昇順で含む配列です。
if (count($CruiseDetailsSailing) > 0) {
$date = array();
$month = array();
$Year = array();
for ($n = 0; $n < count($CruiseDetailsSailing); $n++) {
if ($CruiseDetailsSailing[$n] != "") {
$date[] = date('Y-m-d', strtotime($CruiseDetailsSailing[$n]));
}
}
}
sort($date);
if (count($date) > 0) {
$temp = "";
$yeartemp = "";
for ($p = 0; $p < count($date); $p++) {
$month = date("M", strtotime($date[$p]));
$day = date("d", strtotime($date[$p]));
$year = date("Y", strtotime($date[$p]));
if ($month != $temp) {
$temp = $month;
?>
<li> <?php
echo $temp . " " . $day . ", ";
} else {
echo $day . ", ";
}
if (($p != 0) && ((date("M", strtotime($date[$p]))) == (date("M", strtotime($date[$p - 1])))) && ((date("Y", strtotime($date[$p]))) == (date("Y", strtotime($date[$p - 1]))))) {
echo $year;
}
if (($p != 0) && ((date("M", strtotime($date[$p]))) != (date("M", strtotime($date[$p - 1])))) && ((date("Y", strtotime($date[$p]))) != (date("Y", strtotime($date[$p - 1]))))) {
echo $year;
}
}
Oct は月、10、12、24 は月、2012 は年です。2012 年 10 月 10 日、2012 年 10 月 12 日、2012 年 10 月 24 日の日付を取得しました。ありがとう、