gpt4 book ai didi

php - 如何生成过去的随机日期?

转载 作者:行者123 更新时间:2023-12-04 13:51:10 24 4
gpt4 key购买 nike

使用 PHP。

它必须是有效的,例如:
2001-6-28 14:20:29
?

(如果可能的话,不超过 10 年)

最佳答案

unix 时间戳是一个从 0 到 n 的整数,所以你可以在 php 中使用普通的随机方法:)

$timestamp = rand(0, time() - 60*60*24*365*10);

// Prints something like: Monday 8th of August 2005 03:12:46 PM
echo date('l jS \of F Y h:i:s A', $timestamp);

关于php - 如何生成过去的随机日期?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7381889/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com