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;
?>

Komentar

Postingan populer dari blog ini

Mengatasi Masalah Foreign Key Constraint Ketika Migrasi Database di Laravel 5.4

Solving app is not indexable by google search consider adding at least one activity with an action-view