Page 1 of 1

trouble in email with php and js datepicker

Posted: Thu Apr 07, 2011 10:20 am
by keccos
Hi all,
i'm using a js datepicker in a form, but when I receive the mail with the form datas, the dates are numbers like 1302000813 and i cannot understand!
here is the code of my php file:

Code: Select all

<?php
$to = "my@email.com";

$subject = "Subject";


$body = "Content:\n\n";

$body .= "name: " . trim(stripslashes($_POST["name"])) . "\n";
$body .= "surname: " . trim(stripslashes($_POST["surname"])) . "\n";
$body .= "email: " . trim(stripslashes($_POST["email"])) . "\n";
$body .= "phone: " . trim(stripslashes($_POST["phone"])) . "\n";
$body .= "entrydate: " . trim(stripslashes($_POST["entrydate"])) . "\n";
$body .= "goingoutdate: " . trim(stripslashes($_POST["goingoutdate"])) . "\n";
$body .= "writeus: " . trim(stripslashes($_POST["writeus"])) . "\n";

$headers = "From: Reservation";

if(@mail($to, $subject, $body, $headers)) {

echo "Your email has been sent correctly. Thank you!";

} else {

echo "There was a problem while sending the mail. Please contact us. Thank you!";

}

?>
where i'm wrong? thanks

ps i tried to change something putting
$body .= "entrydate: " . trim(date($_POST["entrydate"])) . "\n";
$body .= "goingoutdate: " . trim(date($_POST["goingoutdate"])) . "\n";
but is the same...

thanks again
Kecco

Re: trouble in email with php and js datepicker

Posted: Thu Apr 07, 2011 11:52 am
by litebearer
that number is a timestamp - use
$date1=date("Y-m-d", $ts);
where you set $ts to the value returned by your post

Re: trouble in email with php and js datepicker

Posted: Thu Apr 07, 2011 1:47 pm
by keccos
i pought:

$body .= "entrydate: " . trim(date("d-m-Y", $_POST["entrydate"])) . "\n";
$body .= "goingoutdate: " . trim(date("d-m-Y", $_POST["goingoutdate"])) . "\n";

and now works. Thanks a lot mate