douliudong8108 2012-12-16 13:02
浏览 30
已采纳

改变从美国格式到英国的数组元素

I am pulling in movie data from an external API to create a database similar to IMDb for my final year university project, and the release date information is formatted as YYYY-MM-DD (i.e 16 December 2012 is displayed as 2012-12-16, rather than 16-12-2012). Is there any way to reorder the segments of the array to reshuffle them for a British English audience?

The raw result of the release date is as follows, gleaned from the getMovieReleases function in the TMDb API (N.B. to save on post size, I've only copied in the first 10 results from the getMovieReleases function):

[id] => 17578
    [countries] => Array
        (
            [0] => Array
                (
                    [iso_3166_1] => US
                    [certification] => PG
                    [release_date] => 2011-12-21
                )

            [1] => Array
                (
                    [iso_3166_1] => DE
                    [certification] => 6
                    [release_date] => 2011-10-27
                )

            [2] => Array
                (
                    [iso_3166_1] => FR
                    [certification] => 
                    [release_date] => 2011-10-26
                )

            [3] => Array
                (
                    [iso_3166_1] => TR
                    [certification] => 
                    [release_date] => 2011-11-04
                )

            [4] => Array
                (
                    [iso_3166_1] => DK
                    [certification] => 7
                    [release_date] => 2011-10-27
                )

            [5] => Array
                (
                    [iso_3166_1] => GB
                    [certification] => PG
                    [release_date] => 2011-10-26
                )

            [6] => Array
                (
                    [iso_3166_1] => FI
                    [certification] => 12
                    [release_date] => 2011-11-04
                )

            [7] => Array
                (
                    [iso_3166_1] => IT
                    [certification] => T
                    [release_date] => 2011-10-28
                )

            [8] => Array
                (
                    [iso_3166_1] => SE
                    [certification] => 
                    [release_date] => 2011-10-28
                )

            [9] => Array
                (
                    [iso_3166_1] => NL
                    [certification] => 6
                    [release_date] => 2011-10-26
                )

            [10] => Array
                (
                    [iso_3166_1] => BE
                    [certification] => 
                    [release_date] => 2011-10-26
                )
        )

)

I am calling the data in my PHP & HTML as follows, only picking out the US and UK release dates:

$releases = $tmdb->getMovieReleases($tmdb_id);

$uk = $releases['countries']['14']['release_date'];
$us = $releases['countries']['0']['release_date'];

<section>
    <p class="title">RELEASE DATE</p>
    <p class="section_body">
        <?php echo $uk; ?> (UK)<br>
        <?php echo $us; ?> (US)
    </p>
</section>
  • 写回答

2条回答 默认 最新

  • doutuan9357 2012-12-16 13:09
    关注
    $uk = date('d/m/Y', strtotime($releases['countries']['14']['release_date']));
    

    That should point you in the right direction..

    see date() and strtotime()

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题