Add date to an email

Hi there!
I hope you can help me.
On my website, when a client fill a form, we will receive an email with the client’s deatils, such as Name, surname, email… but I was trying to add the time and date when the client filled the form on the email.
That’s my code below:

$headers = "From:[email protected]\n" . “MIME-Version: 1.0\n” . “Content-type: text/html; charset=UTF-8”;
$en_email = "[email protected]";
$subject = “New”;
$en_firstname = $_POST[“en_firstname”];
$en_surname = $_POST[“en_surname”];
$en_email = $_POST[“en_email”];
$en_phone = $_POST[“en_phone”];
$en_course = $_POST[“en_course”];
$en_price = $_POST[“en_price”];
$timestamp = $_POST[“timestamp”];
$message = ’













Course Details Date: ‘.$timestamp.’
  Course: ‘.$en_course.’
  Price: ‘.$en_price.’
     
Lead Details Name: ‘.$en_firstname.’ ‘.$en_surname.’
  Email: ‘.$en_email.’
  Phone: ‘.$en_phone.’
Address: Adddress: ‘.$per_add_1.’ ‘.$per_add_2.’
  Town: ‘.$per_town_city.’
  County: ‘.$per_country.’
  Postcode: ‘.$per_postcode.’

';
wp_mail($en_email,$subject,$message,$headers);

Thank you!

Well, I use this line to grab the date and time:

[php]
$timestamp = date(“Y-m-d H:i:s”);
[/php]
This version is formated as 2015-11-19 19:56:33 , but, you can reformat it to fit your email…
Then, just echo it in your $message where you want it displayed.

One note, remember this is the server’s time which is not always what you want. There are ways to adjust
it to their local date/time, but, I usually do not bother. Hope this helps!

PS: Next time, please place your code inside of the PHP tags. You press the PHP button above and then
insert your code between them. Makes it so much better for us to copy it…

Sponsor our Newsletter | Privacy Policy | Terms of Service