drrhr20884 2017-06-21 08:00
浏览 14
已采纳

使用split或implode拆分PHP变量

I want to split the date variable in php.

Here I declare PHP variable like: $date = 20170501;

and I want the result like this: $date = 2017-05-01

How can I achieve this?

  • 写回答

1条回答 默认 最新

  • drbouzlxb92333332 2017-06-21 08:07
    关注

    Simple and easy way:

    <?php
        echo date('Y-m-d', strtotime("20170501"));
    ?>
    

    Example: https://eval.in/819801

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

报告相同问题?