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.
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";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With