im trying to simply format a timestamp in a php $_POST to format "MonthName dd, yyyy, hh:mm am/pm"
the global post variable is $_POST['Time'] that holds my timestamp and is currently showing the default format "2021-09-25 18:17:36"....how can i format this timestamp into "MonthName dd, yyyy, hh:mm am/pm" format?
CodePudding user response:
<?php
// Figure out the format you want to convert to
$format = 'Y-m-d';
$date = date($format, strtotime($_POST['Time']));
This page includes what the letters mean when formatting a date in PHP: https://www.php.net/manual/en/datetime.format.php