我正在使用一个剪切粘贴代码,它会分解时间和日期戳,以这种格式 DD/MM/YY HH:MM:SS PM 将其保存在 mysql 中。当它执行时,日期固定为 16/01/13,时间固定为 11:59。我不太了解php,所以不知道出了什么问题。
这是代码
$datm9=date("d/m/y h:i:s A");
//explode the date
$datm_pass=explode(" ",$datm9);
$datm_pass_set = $datm_pass[1].$datm_pass[2];
$hours_test = explode(":",$datm_pass[1]);
$hours_t = $hours_test[0];
$hoursext_t =$datm_pass[2];
//if only for the date
if(($hours_t=='12' && $hoursext_t=='AM')or ($hours_t=='01' && $hoursext_t=='AM') or ($hours_t=='02' && $hoursext_t=='AM') or ($hours_t=='03' && $hoursext_t=='AM')){
$datm_pass_set_d = explode("/",$datm_pass[0]);
$fd=($datm_pass_set_d[0]-1);
$dat_fix = $fd."/".$datm_pass_set_d[1]."/".$datm_pass_set_d[2];
//09/11/11 11:59:49 AM
$datm = $dat_fix." "."11:59:49 AM";
//$datm=date("d/m/y h:i:s A");
$today=$dat_fix;
}else{
$datm=date("d/m/y h:i:s A");
$today=date('d/m/y');
}