s" /> s" />
PHP生成指定范围内单个的时间戳 调用方法: php生成指定范围内多个随机的时间 函数调用方法: 输出结果: array(5) { [0]=> string(19) "2020-04-21 04:04:47" [1]=> s
ion randomDate_array($begintime, $endtime,$is = true,$num = 5){ $i=0; $begin = strtotime($begintime); $end = strtotime($endtime); $array = array(); while ($i < $num){ $date = rand($begin, $end); $array[] = $is ? date("Y-m-d H:i:s",$date) : $date; $i++; } sort($array); return $array;}?>
函数调用方法:
输出结果:
array(5) { [0]=> string(19) "2020-04-21 04:04:47" [1]=> string(19) "2020-04-22 12:40:53" [2]=> string(19) "2020-04-26 18:30:19" [3]=> string(19) "2020-04-28 00:27:15" [4]=> string(19) "2020-04-29 02:56:53"}
来源地址:https://blog.csdn.net/qq_37448303/article/details/126883685
--结束END--
本文标题: php随机生成某个时间段内的时间
本文链接: https://www.lsjlt.com/news/414263.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0