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条)

报告相同问题?

悬赏问题

  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据