在PHP中,可以使用strtotime()
函数将日期转换为时间戳。strtotime()
函数接受一个日期字符串作为参数,并返回对应的时间戳。
下面是一个示例:
$date = "2022-01-01";
$timestamp = strtotime($date);
echo $timestamp;
输出结果将是1640995200
,表示2022年1月1日的时间戳。
注意:strtotime()
函数还支持其他格式的日期字符串,如"now"
表示当前时间,"tomorrow"
表示明天,"+1 day"
表示加一天等等。
上一篇:php怎么把html标签去除?
下一篇:php如何替换数组的值
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站