I MySQL skal du bare gøre MONTH(date)
, YEAR(date)
osv. I PHP kan du gøre date('g', strtotime($datefromsql))
for at få f.eks. 12-timers format time fra datoen.
Så i dit eksempel ovenfor kan du enten gøre
SELECT YEAR(date),
MONTH(date),
DAYOFMONTH(date),
HOUR(date),
MINUTE(date),
SECOND(date)
eller i PHP,
$time = strtotime($datefromsql);
echo date('Y', $time);
echo date('m', $time);
echo date('d', $time);
echo date('h', $time);
echo date('i', $time);
echo date('s', $time);