dsuw85815 2017-07-20 14:09
浏览 681
已采纳

PHP - 将日期转换为YYYY-MM-DDTHH:MM:SS

I was wondering if it was possible to format todays date to below format:

YYYY-MM-DDTHH:MM:SS

It's important that the "T" is preserved, like this:

2017-07-20T00:00:00

Below I have:

$invoice_date = date('Y-m-d H:i:s');

I can't figure out how to add the "T" in between.

  • 写回答

3条回答 默认 最新

  • doutui6241 2017-07-20 14:12
    关注

    T is a format character so you can't use it directly. Escape it (\T) to get a literal T character:

    http://php.net/manual/en/function.date.php

    You can prevent a recognized character in the format string from being expanded by escaping it with a preceding backslash.

    $invoice_date = date('Y-m-d\TH:i:s');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 asp.textbox后台赋值前端不能显示什么原因
  • ¥15 宇视监控服务器无法登录
  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥15 DruidDataSource一直closing
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误