I'm creating one simple blog script and I have this problem:
In MySQL I'm saving PostDate
as TIMESTAMP
, and when I select from MYSQL PostDate
looks like this 2015-10-25 13:53:35
, but I want to convert this timestamp to H:M D-M-Y
. I'm created one function for converting but I don't know how to use it for key PostDate
in array. Exactly I want to rewrite all PostData
keys in array to new format. I know how to do it with foreach
loop but I cant do this because I use Smarty Template Engine.
ConvertTimestamp():
public function ConvertTimestamp($Timestamp)
{
$TimeDate = explode(' ', $Timestamp);
$Date = explode('-', $TimeDate['0']);
$Date = $Date[2].'-'.$Date['1'].'-'.$Date['0'];
$Time = explode(':', $TimeDate['1']);
$Time = $Time['0'].':'.$Time['1'];
$TimeDate = $Time.' '.$Date;
return $TimeDate;
}