How to get time from datetime
datetime, mysql, php
Solution
Do the OOP way
<?php
$date1="30-12-1899 9:25:52 AM";
$format = 'd-m-Y H:i:s A';
$date = DateTime::createFromFormat($format, $date1);
echo $date->format('H:i:s A') . "\n";
Problem
I have datetime `30-12-1899 9:25:52 AM` here needed only time that is `9:25:52 AM` .this time i wanted to insert in `mysql` database and this field has data type time. my code is : ``` <?php $date = "30-12-1899 9:25:52 AM"; $date = strtotime($date); echo date('H:i:s', $date); ?> ``` when execute it returns: ``` 01:00:00 ``` i am not getting where is the problem.Can any one help me on this. thank you.