This topic is locked

Date format in Code Snippet

3/5/2015 1:43:40 PM
PHPRunner General questions
B
bcritchley author

I have a very simple form that sends the customer an email through our SMTP server after record added. I used the send simple email code provided in the program below. When I get the email the date is being formatted as yyy-mm-dd hh:mm:ss. I am trying to get the date to format in the email as MM-DD-YYYY.
$email=$values['Requestor_Email_Address'];

$from="central.stores@greececsd.org";

$msg="Thank you for using the electronic courier request submission form. We have received your request and will expedite promptly. The details of your request are in the email below"."\r\n\n";

$subject="Courier Request";
$msg.= "Name: ".$values['Requestor_Name']."\r\n";

$msg.= "Email: ".$values['Requestor_Email_Address']."\r\n";

$msg.= "Request Number: ".$values['Request_Number']."\r\n";

$msg.= "Date needed: ".$values['Date_To_Be_Picked_Up']."\r\n";

$msg.= "Pickup from: ".$values['Pickup_Location']."\r\n";

$msg.= "Deliver to: ".$values['Destination_Location']."\r\n";

$msg.= "Request: ".$values['Items_To_Be_Moved']."\r\n";
$ret=runner_mail(array('to' => $email, 'bcc' => 'brent.critchley@greececsd.org', 'subject' => $subject, 'body' => $msg, 'from'=>$from));

if(!$ret["mailed"])

echo $ret["message"];

Admin 3/5/2015

You need to use PHP date() function to format date values.
Check this article for inspiration:

http://stackoverflow.com/questions/136782/convert-from-mysql-datetime-to-another-format-with-php
More info on PHP's date function:

http://php.net/manual/en/function.date.php

B
bcritchley author 3/6/2015



You need to use PHP date() function to format date values.
Check this article for inspiration:

http://stackoverflow.com/questions/136782/convert-from-mysql-datetime-to-another-format-with-php
More info on PHP's date function:

http://php.net/manual/en/function.date.php


I know the following is not giving me the output I am looking for. I am brand new to PHP and am obviously missing something?
$msg.= "Date needed: ".date (("l,M,d,Y"),$values['Date_To_Be_Picked_Up'])."\r\n";
Would just like the date output to be "Day, Month, Date, Year" without the time stamp. I looked at the references above, and am not sure what I am missing?

Admin 3/6/2015

You are missing strtotime() part. Please take another look at http://stackoverflow.com/questions/136782/convert-from-mysql-datetime-to-another-format-with-php, first reply provides the answer.