I need help with date format. I am reading a date from sql using php and then I want to format this date to show the month name instead of month number.
Also I need this when I enter the date in an Input type=“date”.
My code is:
$sql = 'SELECT * FROM table';
$stmt = $connection->prepare($sql);
$stmt -> execute([]);
$projects = $stmt -> fetchAll ();
foreach ($projects as $project){
echo $project->projectDate; where projectDate is a date type field in SQL
}
I want this echo to convert the date and show the month. It is a confusion because you never know what the month is.
Also, I have an input type=date on a form and I want to get it’s value from a php code and write it on the screen. Also, how can I get the month name from this input.
I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.