在处理一个发送日期的PHP表单时,我从输入表单中创建了一个时间/日期。(jquery datepicker)
$dateinput = $_POST['datepicker'];
$t1 = date_create($dateinput);
//times are posted seperate and stipped from a input box (either 1055 or 10:55)
$t1_hour = substr($t1_raw,0,2);
$t1_min = substr($t1_raw,-2);
$t1->add(new DateInterval('PT' . $t1_hour . 'H'));
$t1->add(new DateInterval('PT' . $t1_min . 'M'));
print_r($t1);
这一切似乎都奏效了
DateTime Object ( [date] => 2023-09-04 10:55:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam )
但当我试图提取yaer的日期时,它无法处理这些数据,并且一无所获。
echo date('z',$t1);
我可以打印信息
$datetime_1 = date_format($t1, 'm-d-Y H:i');
echo $datetime_1;
同样有效并返回:09-04-2023 10:55
echo('z',$datetime_1);
返回0
我在哪里俯瞰什么?
print_r(getDate($datetime_1));
不知怎的完全崩溃了
Array (
[seconds] => 9
[minutes] => 0
[hours] => 1
[mday] => 1
[wday] => 4
[mon] => 1
[year] => 1970
[yday] => 0
[weekday] => Thursday
[month] => January
[0] => 9
)