douweiluo0600 2014-06-05 15:37
浏览 68
已采纳

从php获取当前时间/日期,格式类似于2012-04-24T00:00:00Z

How can I get php to provide me a string I can compare with the datestring format 2012-04-24T00:00:00Z?

I'm seeing lots of ways to get this from SQL, but I'm getting these dates from a webservice and am trying to filter lots of them with as little manipulation as possible. My hope is to get the current date / time from php in the SQL format and just try a string based comparison.

EDIT: I had erroneously thought this was SQL format, which probably explains some of the difficulties I had trying to find an answer to this question. I'm not sure what standard it is, but I was told this is a popular convention.

  • 写回答

1条回答 默认 最新

  • dplm47571 2014-06-05 15:39
    关注

    Just use date() with the proper formatting flags:

    $date = date("Y-m-d\TH:i:s\Z");
    

    Demo

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题