表单正在从MySQL数据库中检索数据。
$query = $link->query("SELECT Date_ggmmaaaa AS Date
FROM table
WHERE Date_aaaammgg BETWEEN CURDATE() + 0 - INTERVAL 1 MONTH + 0 AND CURDATE() + 0");
while($result = $query->fetch_object) {
$date.= "<string>".$result->date."</string>";
}
现在当我回复$date
时,总是gg.mm.aaaa
我想加1天。
例如,如果我有:
09.02.2013 -> I want to echo 10.02.2013
10.02.2013 -> I want to echo 11.02.2013
我怎样才能达到目的?
编辑:
工作顺利解决方案
$query = $link->query("SELECT date_ggmmaaaa AS date, test FROM table WHERE date_aaaammgg BETWEEN CURDATE() + 0 - INTERVAL 1 MONTH + 0 AND CURDATE() + 0 AND div1 = 0 AND div4 <> 0");
while($result = mysqli_fetch_array($query)) {
$dt = DateTime::createFromFormat('d.m.Y', $result['date']);
$dt->modify('+1 day');
$result['date'] = $dt->format('d.m.Y');
$date .= "<string>".$result['date']."</string>";
$test .= "<number>".$result['test']."</number>";
}
答案 0 :(得分:2)
$dt = DateTime::createFromFormat('d.m.Y', $result->date);
$dt->modify('+1 day');
$result->date = $dt->format('d.m.Y');
答案 1 :(得分:0)
$result->date=$result->date+86400; //<-- Try that
答案 2 :(得分:0)
也许,你可以用这个:
echo date('d.m.Y', strtotime("+1 day",strtotime('10-02-2013')));
答案 3 :(得分:0)
因为你使用圆点,你可能必须先爆炸:
$tmp = explode(".",$result->date);
echo date("d.m.Y", mktime(0, 0, 0, $tmp[1], $tmp[0]+1, $tmp[2]));