$start="2007-11-1";
$end="2007-12-5";
然后用strtotime将这个两个字符串的日期变成时间戳,然后循环,每次加86400(秒),然后在插入前再次将时间戳用date("Y-m-d", $timestamp);转换回字符串。
insert into table set date='$date'就可以。

解决方案 »

  1.   

    问题似乎已经解决
    $sm=2; 
    $sd=23; 
    $sy=2007;  $em=3; 
    $ed=14; 
    $ey=2007; 

    //utc of start and end dates 
    $s=mktime(0,0,0,$sm, $sd, $sy); 
    $e=mktime(0,0,0,$em, $ed, $ey); 

    while($s<=$e){ 
    print date('Y-m-d',$s)."< br >"; //display date in  mySQL format 
    $s=$s+86400; //increment date by 86400 seconds(1 day) 请问如何比较时间大小。
      

  2.   

    $days=(strtotime("2007-12-5")-strtotime("2007-11-1"))/(60*60*24);
    for($i=0;$i<$days;$i++){
      $date=date('Y-m-d',strtotime("2007-11-1",+$i day));
      //INSERT   into   table   SET   date='$date';
    }
      

  3.   

    //INSERT   into   table   SET   date='2007/11/1'; 这是什么数据库的sql语法...如果这样的操作比较频繁,建议你还是建立一张字典表,列出你要的所有日期,10年也就3000多记录然后用
    insert into table1 select data from table2 where date between @date_f and @date_t