0

表单正在从 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>";

}

现在,当我 echo 时,我$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>";
}
4

4 回答 4

2
$dt = DateTime::createFromFormat('d.m.Y', $result->date);
$dt->modify('+1 day');
$result->date = $dt->format('d.m.Y');
于 2013-02-10T00:53:26.300 回答
0
$result->date=$result->date+86400;  //<-- Try that
于 2013-02-10T00:52:51.573 回答
0

也许,你可以使用这个:

echo date('d.m.Y', strtotime("+1 day",strtotime('10-02-2013')));
于 2013-02-10T00:53:27.207 回答
0

因为您使用点,所以您可能必须先爆炸:

$tmp = explode(".",$result->date);
echo date("d.m.Y", mktime(0, 0, 0, $tmp[1], $tmp[0]+1, $tmp[2]));
于 2013-02-10T00:58:14.700 回答