短视频平台开发,查找日期和时间的数组
作者:互联网
短视频平台开发,查找日期和时间的数组实现的相关代码
01.查找当前日期和时间
$time = date('Y-m-d H:i:s');
echo $time;
var_dump(date('r'));
//打印 Thu, 29 Jul 2021 10:05:08 +0800
getdate — 取得日期/时间信息
$today = getdate();
print_r($today);
Array
(
[seconds] => 21
[minutes] => 9
[hours] => 10
[mday] => 29
[wday] => 4
[mon] => 7
[year] => 2021
[yday] => 209
[weekday] => Thursday
[month] => July
[0] => 1627524561
)
localtime - 函数返回本地时间(一个数组)。
$today = localtime(time(),true);
print_r($today);
Array
(
[tm_sec] => 27
[tm_min] => 12
[tm_hour] => 10
[tm_mday] => 29
[tm_mon] => 6
[tm_year] => 121
[tm_wday] => 4
[tm_yday] => 209
[tm_isdst] => 0
)
02.从字符串解析日期和时间
strtotime — 将任何字符串的日期时间描述解析为 Unix 时间戳
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 date('Y-m-d H:i:s',strtotime('+1 month')); //一个月后
以上就是短视频平台开发,查找日期和时间的数组实现的相关代码, 更多内容欢迎关注之后的文章
标签:视频,10,echo,strtotime,日期,tm,today,数组,查找 来源: https://www.cnblogs.com/yunbaomengnan/p/15871096.html