PHP:DATETIME在数组中作为对象。如何回应 [英] PHP: DATETIME in array as object. How to echo

查看:130
本文介绍了PHP:DATETIME在数组中作为对象。如何回应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

希望标题不是太神秘。我有一个DATETIME对象的数组,我只是想弄清楚如何回应一个页面。

  [created] => object(DateTime)#3(3){[date] => string(19)2010-10-22 00:00:00[timezone_type] => int(3)[timezone] =>字符串(13)欧洲/伦敦

有人可以帮助我吗?



尝试date()但是得到:

 警告:date()期望参数2为长的,在C:\ 

中给出的对象最受赞赏的任何帮助,



琼斯

解决方案

http://www.php.net/manual/en/datetime.format.php



echo $ date_format(myArray [created],你希望的日期格式);

  

格式:



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


Hope that title isn't too cryptic. I have an array with a DATETIME object in it and I'm just trying to figure out how to echo this to a page.

 ["created"]=> object(DateTime)#3 (3) { ["date"]=> string(19) "2010-10-22 00:00:00" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/London"

Can someone help me out?

tried date() but get:

Warning: date() expects parameter 2 to be long, object given in C:\

any help most appreciated,

Jonesy

解决方案

http://www.php.net/manual/en/datetime.format.php

echo date_format(myArray["created"], "the format you want for your date");

Formatting:

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

这篇关于PHP:DATETIME在数组中作为对象。如何回应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆