本文整理匯總了PHP中DateHelper::date_select方法的典型用法代碼示例。如果您正苦於以下問題:PHP DateHelper::date_select方法的具體用法?PHP DateHelper::date_select怎麽用?PHP DateHelper::date_select使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DateHelper
的用法示例。
在下文中一共展示了DateHelper::date_select方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testDate_select_method
/**
* Test date_select_method()
*
* Test the {@link DateHelper::date_select()} method
*/
public function testDate_select_method()
{
$dh = new DateHelper('Person', 'birthdate');
$_REQUEST['Person']['birthdate(1i)'] = '1955';
$_REQUEST['Person']['birthdate(2i)'] = '08';
$_REQUEST['Person']['birthdate(3i)'] = '13';
// Test with default format
$this->assertEquals('<select name="Person[birthdate(1i)]">' . "\n" . '<option value="1950">1950</option>' . "\n" . '<option value="1951">1951</option>' . "\n" . '<option value="1952">1952</option>' . "\n" . '<option value="1953">1953</option>' . "\n" . '<option value="1954">1954</option>' . "\n" . '<option value="1955" selected="selected">1955</option>' . "\n" . '<option value="1956">1956</option>' . "\n" . '<option value="1957">1957</option>' . "\n" . '<option value="1958">1958</option>' . "\n" . '<option value="1959">1959</option>' . "\n" . '<option value="1960">1960</option>' . "\n" . '</select>' . "\n" . ' <select name="Person[birthdate(2i)]">' . "\n" . '<option value="01">January</option>' . "\n" . '<option value="02">February</option>' . "\n" . '<option value="03">March</option>' . "\n" . '<option value="04">April</option>' . "\n" . '<option value="05">May</option>' . "\n" . '<option value="06">June</option>' . "\n" . '<option value="07">July</option>' . "\n" . '<option value="08" selected="selected">August</option>' . "\n" . '<option value="09">September</option>' . "\n" . '<option value="10">October</option>' . "\n" . '<option value="11">November</option>' . "\n" . '<option value="12">December</option>' . "\n" . '</select>' . "\n" . ' <select name="Person[birthdate(3i)]">' . "\n" . '<option value="01">01</option>' . "\n" . '<option value="02">02</option>' . "\n" . '<option value="03">03</option>' . "\n" . '<option value="04">04</option>' . "\n" . '<option value="05">05</option>' . "\n" . '<option value="06">06</option>' . "\n" . '<option value="07">07</option>' . "\n" . '<option value="08">08</option>' . "\n" . '<option value="09">09</option>' . "\n" . '<option value="10">10</option>' . "\n" . '<option value="11">11</option>' . "\n" . '<option value="12">12</option>' . "\n" . '<option value="13" selected="selected">13</option>' . "\n" . '<option value="14">14</option>' . "\n" . '<option value="15">15</option>' . "\n" . '<option value="16">16</option>' . "\n" . '<option value="17">17</option>' . "\n" . '<option value="18">18</option>' . "\n" . '<option value="19">19</option>' . "\n" . '<option value="20">20</option>' . "\n" . '<option value="21">21</option>' . "\n" . '<option value="22">22</option>' . "\n" . '<option value="23">23</option>' . "\n" . '<option value="24">24</option>' . "\n" . '<option value="25">25</option>' . "\n" . '<option value="26">26</option>' . "\n" . '<option value="27">27</option>' . "\n" . '<option value="28">28</option>' . "\n" . '<option value="29">29</option>' . "\n" . '<option value="30">30</option>' . "\n" . '<option value="31">31</option>' . "\n" . '</select>' . "\n", $dh->date_select());
}
示例2: MockAkActiveRecord
function test_DateHelper()
{
$this->assertEqual(DateHelper::distance_of_time_in_words('1978-06-16', '2006-01-18'), '10078 days');
$this->assertEqual(DateHelper::distance_of_time_in_words('1779-12-01', '1780-01-01'), '31 days');
/**
* According to the Gregorian calendar, which is the civil calendar in use today,
* years evenly divisible by 4 are leap years, with the exception of centurial years
* that are not evenly divisible by 400. Therefore, the years 1700, 1800, 1900 and 2100
* are not leap years, but 1600, 2000, and 2400 are leap years.
*/
$this->assertEqual(DateHelper::distance_of_time_in_words('2100-02-01', '2100-03-01'), '28 days');
$this->assertEqual(DateHelper::distance_of_time_in_words('2096-02-01', '2096-03-01'), '29 days');
$this->assertEqual(DateHelper::distance_of_time_in_words('2000-02-01', '2000-03-01'), '29 days');
$this->assertEqual(DateHelper::distance_of_time_in_words('2100-02-01 01:00:00', '2100-02-01 02:50:00'), 'about 2 hours');
$this->assertEqual(DateHelper::distance_of_time_in_words('2100-02-01 01:00:00', '2100-02-01 02:50:00'), 'about 2 hours');
$Person =& new MockAkActiveRecord($this);
$Person->setReturnValue('get', '1978-06-16 04:37:00', array('date'));
$DateHelper = new DateHelper(array('person' => &$Person));
$this->assertEqual(join(array_diff(explode("\n", $DateHelper->date_select('person', 'date')), array(''))), join(array_diff(explode("\n", '<select name="person[date(1i)]">
<option value="1973">1973</option>
<option value="1974">1974</option>
<option value="1975">1975</option>
<option value="1976">1976</option>
<option value="1977">1977</option>
<option value="1978" selected="selected">1978</option>
<option value="1979">1979</option>
<option value="1980">1980</option>
<option value="1981">1981</option>
<option value="1982">1982</option>
<option value="1983">1983</option>
</select>
<select name="person[date(2i)]">
<option value="January">January</option>
<option value="February">February</option>
<option value="March">March</option>
<option value="April">April</option>
<option value="May">May</option>
<option value="June" selected="selected">June</option>
<option value="July">July</option>
<option value="August">August</option>
<option value="September">September</option>
<option value="October">October</option>
<option value="November">November</option>
<option value="December">December</option>
</select>
<select name="person[date(3i)]">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16" selected="selected">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
'), array(''))));
$this->assertEqual(join(array_diff(explode("\n", $DateHelper->date_select('person', 'date', array('include_blank' => true, 'discard_day' => true, 'order' => array('month', 'year')))), array(''))), join(array_diff(explode("\n", '<select name="person[date(2i)]">
<option value=""></option>
<option value="January">January</option>
<option value="February">February</option>
<option value="March">March</option>
<option value="April">April</option>
<option value="May">May</option>
<option value="June" selected="selected">June</option>
<option value="July">July</option>
<option value="August">August</option>
<option value="September">September</option>
<option value="October">October</option>
<option value="November">November</option>
//.........這裏部分代碼省略.........
示例3: date_select
/**
* Make a new DateHelper object and call its date_select() method
* @param string Name of an ActiveRecord subclass
* @param string Name of an attribute of $object
* @param mixed[] Output format options
* @return string Generated HTML
* @uses DateHelper::date_select()
* @see ActiveRecordHelper::to_scaffold_tag()
*/
function date_select($object, $attribute, $options = array())
{
$date_helper = new DateHelper($object, $attribute);
return $date_helper->date_select($options);
}