1

現在の日付と一致させて現在の誕生日を表示しようとしています。Mysqlの日付形式は1990年9月16日だったので、現在の日付から年をトリミングして9月16日にエコーしました。現在の日付が行の日付と等しい場合、エコーする方法を説明します。以下の方法を試してみましたが、エラーでした。

$timezone = new DateTimeZone("Asia/Kolkata" );
$date = new DateTime();
$date->setTimezone($timezone );
$date2= $date->format( 'd M' );
$date4=date('d M', strtotime($date2));


<?php $sel = $db->query("select * from mov_birthday where date('d M', strtotime(dateofb)) == '$date4' order by dateofb"); 

while($row=mysql_fetch_array($sel)){

echo ($row['name']); } ?>
4

1 に答える 1

1

あなたが使用することができますlike

// this will select every date that starts with date('d M') - day Month
$timezone = new DateTimeZone("Asia/Kolkata" );
$date = new DateTime();
$date->setTimezone($timezone);
$dateFormat = $date->format( 'd F' );
$sel = $db->query("SELECT * FROM `mov_birthday` where `dateofb` LIKE '".$dateFormat."%' ORDER BY `dateofb`");
while($row = $sel->fetch(PDO::FETCH_ASSOC)) {
    echo $row['name'];
}
于 2012-09-15T21:09:11.717 に答える