简体   繁体   English

如何使用php检查请求日?

[英]How can I check request day with php?

For example: x user booking ticket on monday and ticket status changing as book. 例如:x用户在星期一预订机票,并且机票状态更改为预订。 After three days, ticket status will change as free(empty) automatically. 三天后,票务状态将自动更改为免费(空)。 How can I do this? 我怎样才能做到这一点?

Try something like this (using strtotime ): 尝试这样的事情(使用strtotime ):

if ($ticket_timestamp < strtotime("-3 days")) {
  // ticket is expired
}

You will usually want to check this by date. 您通常需要按日期检查。 If you don't care about the actual date but just need to compare, you can use the time() function. 如果您不关心实际日期,而只需要比较,则可以使用time()函数。 The day is time()/60/60/24 . 这天是time()/ 60/60/24。

You can store the timestamp of the order in the database and then compare it with the current time. 您可以将订单的时间戳存储在数据库中,然后将其与当前时间进行比较。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM