各位大家好,感谢您花时间阅读本文;
如果我的变量包含这样的格式化日期,我就会徘徊:
07/02/2012
我通过以下查询获得
date_format(data,'%d/%m/%Y') as data_scadenza,
如何循环使用此日期:
2012-02-07 11:53:00, 2012-02-07 11:54:00, 2012-02-07 11:55:00, etc.
提前感谢大家,在PHP中或直接在MySQL查询中徘徊如何做到这一点。
答案 0 :(得分:2)
在PHP中循环播放。
$num = 5; //5 values will be printed
$phpdate = strtotime('07/02/2012'); //converts to timestamp
$phpdate += 11*3600 + 53*60; //to set initial offset to 11:53:00
for($i=0;$i<$num;$i++)
echo date( 'Y-m-d H:i:s', $phpdate + 60*$i).",";
输出:
2012-07-02 11:53:00,2012-07-02 11:54:00,2012-07-02 11:55:00,2012-07-02 11:56:00,2012-07-02 11:57:00,
答案 1 :(得分:0)
使用值为1到100的数字表并使用此
select date_format(data+interval number minute,'%d/%m/%Y') as data_scadenza your_table as t1
cross join number_table as num