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

Mengatasi Tampilan Tidak Rapih pada Saat Instalasi Awal OJS 3

Mengatasi Masalah No Hint Path Define for [datatables] di Laravel 5.4 dan Yajra 7.0