Splitting Datetime into A Date and A Time Value
An example of a standard format at MySQL for datetime is 2015-06-02 18:24:42. Simple way to split a datetime (2015-06-02 18:24:42) into just the date
(02-06-2015) and the time (18:24:42) using PHP are as follows:
<?php
$tglwaktu = '2015-06-02 18:24:42';
$tgl = date('d-m-Y', strtotime($tglwaktu));
$waktu = date('H:i:s', strtotime($tglwaktu));
echo $tgl. "<br/>";
echo $waktu;
?>
<?php
$tglwaktu = '2015-06-02 18:24:42';
$tgl = date('d-m-Y', strtotime($tglwaktu));
$waktu = date('H:i:s', strtotime($tglwaktu));
echo $tgl. "<br/>";
echo $waktu;
?>
Komentar