douyalin0847 2013-04-12 19:38
浏览 58
已采纳

Php表单处理程序 - 日期格式

I'm using a PHP mail handler to send an enquiry foom from my website.

All is working well except that I would rather the date be formatted differently.

Currently it's sending the date as yyyy-mm-dd and I would like it to be dd-mm-yyyy or a long date such as dd-month-yyyy.

<?php
$myWeb = "My Website";
$name = trim($_POST['name']);
$email = trim($_POST['email']);
$number = trim($_POST['number']);
$message = trim($_POST['message']);
$date = trim($_POST['date']);

$EmailTo = "mymail@myweb.com";

$Subject = "Enquiry from $myweb"; /// Add a subject

$Body = "$name has made an enquiry about: $myWeb

";

$Body .= "Name:  $name

";

$Body .= "Email Address:  $email

";

$Body .= "Contact Telephone Number:  $number

";

$Body .= "Date of Event:  $date

";

$Body .= "$name's Enquiry:

$message

";


if($Subject == NULL) {$Subject = "From $myWeb";}
$success = mail($EmailTo, $Subject, $Body, "From: $myWeb");

if ($success){ 

header('Location: contact-form-thank-you.html','_self');

}
?>

Any ideas please how I would change the format?

  • 写回答

4条回答 默认 最新

  • drvpvmz16241016 2013-04-12 19:46
    关注

    Just saw your update:

    This should help:

    $date = trim($_POST['date']);
    $newDate = date("m-d-Y", strtotime($date));
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?