在我的phpmyadmin数据库中,年份保存为YYYY-MM-DD。但是当我生成pdf时,我想将其更改为DD-MM-YYYY。
代码:
$pdf->Table("SELECT measurements.title as Maling, routines.value as Verdi, routines.date as Dato, routines.time as Tid, pools.name as Basseng, emps.user_name as Ansatt
FROM routines, measure_routine, measurements, pools, emps
WHERE routines.id = measure_routine.routine_id
AND measure_routine.measure_id = measurements.id
AND (measurements.title Like 'T_%') AND measure_routine.pool_id=pools.id AND routines.emp_id=emps.id AND Date between '".$fraDato."' and '".$tilDato."'
ORDER BY routines.date, routines.time;");
$prop=array('HeaderColor'=>array(255,150,100),
'color1'=>array(210,245,255),
'color2'=>array(255,255,210),
'padding'=>2);
$pdf->Output($downloadfilename."$strf.pdf");
header('Location: '.$downloadfilename."$strf.pdf");
}
答案 0 :(得分:3)
$pdf->Table("SELECT measurements.title as Maling, routines.value as Verdi,
date_format(routines.date as Dato, \"%d-%m-%Y\"), ...
答案 1 :(得分:1)
最好的方法是直接在sql中格式化日期,所以更改:
routines.date as Dato
来:
DATE_FORMAT(routines.date, '%d-%m-%Y') as Dato