sfWidgetFormDate - 未来只有40天,过去只有0天

时间:2011-12-21 10:42:37

标签: php datetime symfony1 symfony-1.4

$years = range(2009, 2020);
$month = range ???;
$days = range ???;

$w = new sfWidgetFormDate(
  array('years' => array_combine($years, $years),
        'month' => array_combine($month, $month),
        'days' => array_combine($days, $days),
)
);

我怎样才能在这个例子中做过0天到过去,40到未来有实际日期?

2 个答案:

答案 0 :(得分:0)

<?php 
$years = array_unique(array(date('Y'), date('Y', strtotime('+40 days'))));
$months = array_unique(array(date('m'), date('m', strtotime('first day of next month')), date('m', strtotime('+40 days'))));
$days = range(date('d'), 31);

答案 1 :(得分:0)

format('Y'); $yr_init = $yr_actual-10; $years = range($yr_actual,$yr_init); 
$this->widgetSchema['bcg_1'] = new sfWidgetFormDate(array('format' => 
    '%day%/%month%/%year%','years'=>array_combine($years, $years))); ?>