• 技术文章 >后端开发 >PHP问题

    php date如何转换时间戳

    藏色散人藏色散人2020-10-23 09:34:45原创887

    php date转换时间戳的方法:首先创建PHP示例文件;然后通过“echo strtotime("now"), "\n";”方法将date转换时间戳即可。

    推荐:《PHP视频教程

    使用strotime函数,代码如下;

    <?php
    echo strtotime("now"), "\n";
    echo strtotime("10 September 2000"), "\n";
    echo strtotime("+1 day"), "\n";
    echo strtotime("+1 week"), "\n";
    echo strtotime("+1 week 2 days 4 hours 2 seconds"), "\n";
    echo strtotime("next Thursday"), "\n";
    echo strtotime("last Monday"), "\n";
    echo strtotime("20170808 23:00:01"), "\n";
    ?>

    a8c3b85d2ce84e02fcf1b4e6f8cd528.png

    扩展资料:

    PHP strtotime() 函数

    1.strtotime,可以将美国英语格式时间字符串转换的函数。

    2.strtotime()可以用英语的自然语言创建某个时刻的时间戳

    3.函数语法:int strtotime(string $time[,int $now])

    4.函数作用:将美国英语格式的日期时间字符串转换成unix时间戳。

    以上就是php date如何转换时间戳的详细内容,更多请关注php中文网其它相关文章!

    声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
    专题推荐:date php
    上一篇:php 除法函数怎么用 下一篇:php怎么删除最后一个字符
    20期PHP线上班

    相关文章推荐

    • 【活动】充值PHP中文网VIP即送云服务器• php如何获取当前毫秒时间戳• php 时间戳转化为时间格式• php 时间戳如何转js• php unix时间戳转换成时间的方法
    1/1

    PHP中文网