このコードは、日付を次のように表示します。13-07-2016 月と年のみを表示したい。例:「2016年7月」 このコードを変更して月と年のみを取得して表示するにはどうすればよいですか? コード:Mysqlデータベースから月のみ表示
<td><?=$this->wll->getDateFormate(6,$row['bill_date'])?></td>
このコードは、日付を次のように表示します。13-07-2016 月と年のみを表示したい。例:「2016年7月」 このコードを変更して月と年のみを取得して表示するにはどうすればよいですか? コード:Mysqlデータベースから月のみ表示
<td><?=$this->wll->getDateFormate(6,$row['bill_date'])?></td>
$date = $row['bill_date'];
$month = date('F', strtotime($date));
$year = date('Y', strtotime($date));
<td><?php echo $month . ' ' . $year; ?></td>
その場合
Thanks a Ton! :) –
あなたは大丈夫です= D –
ディスプレイテキストにスイッチを使用してみてください。このような何か:
var month_number = display_text[3] + display_text[3];
var month;
switch (month_number)
case "01":
month = "Jan";
break;
...
など、他の文字とthath月を表示:strtotime():
$time=strtotime($dateValue);
$month=date("F",$time);
$year=date("Y",$time);
それともような何かを行うことができ
show: display_text[0] + display_text[1] + "-" + month + ...
コードをよく知らないのですが、コードを変更できますか? –
ソーリーファンドンド、私はPHPに熱心ではない。 [String handling](http://php.net/manual/es/ref.strings.php)と[switch structures](http://php.net/manual/es/control-structures.switch.php)を検索してみてください。 ) –
使用...
$dateElements = explode('-', $dateValue);
$year = $dateElements[0];
echo $year; //2012
switch ($dateElements[1]) {
case '01' : $mo = "January";
break;
case '02' : $mo = "February";
break;
case '03' : $mo = "March";
break;
.
.
.
case '12' : $mo = "December";
break;
}
echo $mo; //January
使用したい、そのデータを提供するために、クエリを修正ではなく、それは
SELECT DATE_FORMAT(theDateCol, '%M %Y') as theMonthAndYear, ...
date_format($row['bill_date], "F Y");
Fクエリ投稿を操作しようとしている - >完全な月文字やY - > 4桁の年
をちょっと説明しますか?そうでなければ、それはコメントのように見え、おそらくダウンボックスを得るでしょう – RiggsFolly
'' wll''と 'getDateFomate'は何をするのか分かりません。 –
PHPにいくつかの[日付機能](http://php.net/manual/en/ref.datetime.php)がある場合... – tadman
MYSQLには[日付機能](http://dev.mysql .com/doc/refman/5.7/ja/date-and-time-functions.html#function_date-format) – RiggsFolly