dswg47377 2016-05-09 22:39
浏览 56
已采纳

将php对象DateTime转换为二维数组中的字符串

Hi I have array like as

 Array
  (
   [0] => Array
    (
        [id] => 167
        [title] => hhhhh
        [start] => DateTime Object
            (
                [date] => 2016-05-08 00:00:00.000000
                [timezone_type] => 3
                [timezone] => Europe/Berlin
            )

        [end] => DateTime Object
            (
                [date] => 2016-05-10 00:00:00.000000
                [timezone_type] => 3
                [timezone] => Europe/Berlin
            )

    )

I need output witouch dateTime Object and Timezone etc, only date. I think that my new array should be look like below.

Array
(
[0] => Array
    (
        [id] => 167
        [title] => hhhhh
        [start] => 2016-05-08 00:00:00.000000
        [end]=> 2016-06-08 00:00:00000



    )

How do it work ?

  • 写回答

1条回答 默认 最新

  • doutang2382 2016-05-09 22:47
    关注

    I think it can works fine:

    $result = array();
    foreach($fatherArray as $element)
    {
        $result[] = array("id"    => $element["id"],
                          "title" => $element["title"],
                          "start" => $element["start"]->date,
                          "end" => $element["end"]->date,);
    }
    var_dump($result);
    

    I hope it helps you.

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

报告相同问题?

悬赏问题

  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗