user3432484 user3432484 - 6 months ago 27
PHP Question

Mysql query date format, phpmailer

I am using phpmailer and have it working but I need to change the date format the email is sending. This is working

$body = "Hello <font size=\"4\">" . $row['FirstName'] . "</font>, <p>";
$body .= "<i>Your</i> appointment is scheduled for ".$row['StartTime']. "-" .$row['Date']. "<p>";

The date is sent as 2016-09-11 and I would like September 11 2016 or better again Sunday September 11th

I tried "g:i a F j, Y ", but always end up with syntax error, unexpected ',' in


Instead directly using date values in the string, format dates and then use in the string as like below.

$StartTime = date('g:i a', strtotime($row['StartTime']));
$Date = date('F j, Y', strtotime($row['Date']));

$body = "Hello <font size=\"4\">" . $row['FirstName'] . "</font>, <p>";
$body .= "<i>Your</i> appointment is scheduled for ".$StartTime. " - " .$Date."<p>";

echo $body;

You will get output like below

Hello <username>,

Your appointment is scheduled for 12:30 pm - September 10, 2016

Hope it will help you.