php-7.3 - 如何编写代码以在 2 天后运行
问题描述
您好家人我正在开发一个移动应用程序如果您选择,该应用程序提供多种服务,例如汇款该应用程序必须生成一个唯一的代码,该代码的截止日期为 2 天,我不知道如何帮助我
<?php
include 'my_db.php';
$id=1;
$query = $bdd->prepare("SELECT temps FROM date WHERE ID= '". $id ."' ");
$query->execute();
while(true)
{
$start_date = $query->fetch()[0]; //code creation date
$limit_date = $start_date->modify("+2 day"); //code expiration date
if($start_date >=$limit_date)
{
//your code is invalid
}else
{//your code is valid}
}
?>
我以为我会:代码有效或代码无效
解决方案
我找到了解决方案
`<?php
include 'my_db.php';
$id=1;
$dijaa = $bdd->prepare("SELECT temps FROM date WHERE ID= '". $id ."' ");
$dijaa->execute();
$code_niane = $dijaa->fetch()[0]; //code creation date
$dst_inf1= strtotime($code_niane); //converting time with strtotime
$dsttr2 = time(); // server date
$sabayke = 2*24*60*60; // code expiration date
if($dsttr2-$dst_inf1==$sabayke){ // if date == 2days
// treatment
}else{
//treatment
}
?>`
推荐阅读
- typescript - 打字稿“找不到名称'firebase'” Firebase 保留 URL
- react-native - 在 React Native 中将原始值传递给 onChangeText
- html - 图片库只有一个 div 元素作为行,并以新行显示图像
- spring-boot - Spring Boot 测试 + Kotlin = 无法加载 ApplicationContext
- azure - 显示控件 OutputClaim 的 Azure B2C ClaimsTransformation 错误
- javascript - 使用按钮触发 React Native 中的相机模块?
- python - 从后台任务发出的flask-socketio不会发出
- java - 休眠:OneToMany RelationShip:实体表不接受多个值
- flutter - Flutter(Web)如何监听javascript事件或将javascript数据传递给flutter?
- python - 将选项添加到 tkinter 列表后无法从选项菜单中选择选项