MySql DB
中的值:1396-3-6
此值无效
但1396-03-06
和1379-11-10
已合作!!为什么呢?
MySql DB
中的字段生日为文字utf8_general_ci
如果有效,请在dropdownlist
dropDownList
年是工作,但日和月都不起作用
控制器:
# Day
$days = [];
for($i=1;$i<=31;$i++)
{
$days[$i] = $i;
}
# Month
$month = [
1 => 'Fa',
2 => 'Or',
3 => 'Kh',
4 => 'Ti',
5 => 'Mo',
6 => 'Sh',
7 => 'Me',
8 => 'Ab',
9 => 'Az',
10 => 'De',
11 => 'Ba',
12 => 'Es'];
# Year
$year = [];
$thisYear = General::pDate(time(), 'yyyy');
for($i=$thisYear;$i>=1360;$i--)
{
$year[$i] = $i;
}
$birthDate = explode('-', $model->birthday);
$birthYear = ($birthDate[0] < 10) ? substr($birthDate[0], 1) : $birthDate[0];
$birthMonth = ($birthDate[1] < 10) ? substr($birthDate[1], 1) : $birthDate[1];
$birthDay = ($birthDate[2] < 10) ? substr($birthDate[2], 1) : $birthDate[2];
查看:
<div class="col-xs-3 pull-right selectDay">
<?= Html::dropDownList('birthday', $birthDay, $days, [
'prompt'=> 'Day',
'class' => 'form-control',
]) ?>
</div>
<div class="col-xs-3 pull-right selectMonth">
<?= Html::dropDownList('birthMonth', $birthMonth, $month,[
'prompt'=> 'Month',
'class' => 'form-control',
]) ?>
</div>
<div class="col-xs-3 pull-right selectYear">
<?= Html::dropDownList('birthYear', $birthYear, $year,[
'prompt'=> 'Year',
'class' => 'form-control',
]) ?>
</div>
答案 0 :(得分:0)
我有问题。
substr值更改为0表示开始。