You can Cut the time from the last Space in the string
<?php
$str = "Apr 8 2014 9:52AM";
$date = substr($str, 0, strrpos( $str, ' '));
echo $date;
?>
Output
Apr 8 2014
Question
I have a column in my MSSQL table that was created using part of a PHP query:
order_date datetime NOT NULL DEFAULT GETDATE(),
And whenever a new table row is created, data is put into that column like so:
Apr 8 2014 9:52AM
I would like to display the above column data (Apr 8 2014 9:52AM) in a table using PHP. I would like to only display the month, the day, and the year, and to not display the 9:52AM
.
I am doing this because the 9:52AM is incorrect for my timezone and is supposed to be 10:52AM.
I unfortunately do not have access to my SQL CPanel, so I will not be able to change the timezone universally from there.
So if there is either a way to add 1 hour to the time when a new row is created, or to just not display the time when I echo
the table data, that would be perfect.
Thank you for any help. I appreciate all help.
Solution
You can Cut the time from the last Space in the string
<?php
$str = "Apr 8 2014 9:52AM";
$date = substr($str, 0, strrpos( $str, ' '));
echo $date;
?>
Output
Apr 8 2014