This question already has an answer here:
Please pardon me if this has been asked before (I couldn't find anything), but I have been researching for a very long time and could not find a solution to this particular issue.
Basically, I have a HTML form handled with PHP. In one of the fields of the form I used:
<input type="datetime-local">
This triggers the datepicker in Chrome. The datepicker asks the user to input the date and time in mm/dd/yyyy hh:mm am/pm (12-hour format). That is how I expected the outputted email to look.
But instead it gives the date in this format: yyyy/mm/ddThh:mm (24-hour format)
How can I convert it back to what it is originally?
Current PHP code:
<?php
$to = 'myemail@gmail.com';
$subject = 'Reservations Page';
$headers = "From: \"Visitor Reservations\" <''>";
$headers .= "Reply-To: ". strip_tags($_POST['email']) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = "<html><body><div style='width:500px;'>";
$message .= '<h1 style="display:block; width:96%; padding:2%; text-align:center; color:#FF9900; font-size:22px;">Reservations</h1>';
$message .= '<table rules="all" style="clear:both; width:500px; border-color:white;" cellpadding="10">';
$message .= "<tr style='background-color: #00647F; color:white; width:30%; height:50px; text-align:center; font-size:18px;'><td><strong>NAME:</strong> </td><td style='width:70%; font-style:italic;'>" . strip_tags($_POST['name']) . "</td></tr>";
$message .= "<tr><td style= 'background:#A1EBFC; width:30%;'><strong>Email:</strong> </td><td style='width:70%;'>" . strip_tags($_POST['email']) . "</td></tr>";
$message .= "<tr><td style= 'background:#A1EBFC; width:30%;'><strong>Phone:</strong> </td><td style='width:70%;'>" . strip_tags($_POST['phone']) . "</td></tr>";
$message .= "<tr><td style= 'background:#A1EBFC; width:30%;'><strong>Address:</strong> </td><td style='width:70%;'>" . strip_tags($_POST['address']) . "</td></tr>";
$message .= "<tr><td style= 'background:#A1EBFC; width:30%;'><strong>Date:</strong> </td><td style='width:70%;'>" . strip_tags($_POST['date']) . "</td></tr>";
$message .= "<tr><td style= 'background:#A1EBFC; width:30%;'><strong>Message:</strong> </td><td style='width:70%;'>" . htmlentities($_POST['message']) . "</td></tr>";
$message .= "</table>";
$message .= "</div></body></html>";
if ($_POST['submit']) {
if (mail($to, $subject, $message, $headers)) {
echo '<p style="border:2px solid #39D759; text-align:center; width:100%; padding:2% 0;"> Successfully Sent.</p>';
} else {
echo '<p style="border:2px solid red; text-align:center; width:100%; padding:2% 0;">Message Failed to Send.</p>';
}
}
?>
Aucun commentaire:
Enregistrer un commentaire