trouble in email with php and js datepicker

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
keccos
Forum Newbie
Posts: 2
Joined: Thu Apr 07, 2011 9:43 am

trouble in email with php and js datepicker

Post 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
litebearer
Forum Contributor
Posts: 194
Joined: Sat Mar 27, 2004 5:54 am

Re: trouble in email with php and js datepicker

Post 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
keccos
Forum Newbie
Posts: 2
Joined: Thu Apr 07, 2011 9:43 am

Re: trouble in email with php and js datepicker

Post 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
Post Reply