SITUATION:
I am building a support ticket system where the employee can respond to a ticket. This gets displayed within a sort've chat display, which also includes the time the post was made at.
The date gets stored within a database, and gets saved as a timestamp.
I currently am wondering how I can inject strings inside the retrieved timestamp, since my goal is this:
To display 23-02-2018 09:47:13 as 23-02-2018 {atLabel} 09:47 {$hoursLabel}. In other words this would look in an English version as follows:
23-02-2018 09:47:13 as 23-02-2018 at 09:47 hours
===============================================================
CURRENT DISPLAY:
^ This is achieved by the following Smarty code:
{foreach from=$ticketConversationList item=ticketConversation}
<div class="holder" style="border-radius: 0;">
<i class="pull-right">{$ticketHistoryPostedAt}{$ticketConversation.posted_at}</i>
</div>
{/foreach}
{$ticketConversation.posted_at} = < - This gets fetched using a SQL query on the database, and then the array is send to the foreach using smarty->assign()
NOTICE: This post is not a duplicate of a DATETIME into DD-MM-YYYY HH:MM:SS because my question is specifically about splitting the TIMESTAMP as so I can enter in strings into the display.
You can explode on the base of space then put them together to display in the format you want to
$dateTime = $ticketConversation.posted_at;
$data = explode(" ", $dateTime);
echo $data[0] ." at ".$data[1]." hours";