Reputation: 322
I have a timestamp column in my db. I need to convert timestamp in to date and time respectively.
I use
$timestamp = strtotime($row1['timestamp']);
$date = date('d-m-Y', $timestamp);
$time = date('Gi.s', $timestamp);
When I use this code, I am not getting the time correctly. INPUT: 2017-06-06 08:06:14 OUTPUT: date: 06-06-2017 Time : 806.14
Thanks in Advance
Upvotes: 2
Views: 94
Reputation: 153
Try This
$timestamp='1496736374'; //fetch timestamp value form DB.
$date = date('d-m-Y H:i:s', $timestamp);
dd($date);
Upvotes: 0
Reputation: 811
<?php
$timestamp = strtotime( '2017-06-06 08:06:14');
$date = date('d-m-Y', $timestamp);
$time = date("H:i:s", $timestamp);
echo "$date $time";
?>
This will work.. Hope it helps
Upvotes: 1