给客户把网站开发了后,如何进行时间授权,并在过了授权期后,就完成提醒呢?在这里作一个记录,方便日后使用;<?php//读取页面源代码$url='https://www.diebaoyun.com/rpashouquan/rpachaxun.php?customer_username=%E5%8A%A0%E5%A3%AB%E5%AE%9D';$content=file_get

扫码分享
二维码

详细介绍

给客户把网站开发了后,如何进行时间授权,并在过了授权期后,就完成提醒呢?

在这里作一个记录,方便日后使用; 

<?php
// 读取页面源代码
$url = '**********************************?customer_username=%E5%8A%A0%E5%A3%AB%E5%AE%9D';
$content = file_get_contents($url);
// 提取过期时间
$expirationTime = ''; // 过期时间变量
preg_match('/过期时间:\s*([\d-]+\s+[\d:]+)\s*<br>/', $content, $matches);
if (isset($matches[1])) {
    $expirationTime = trim($matches[1]);
}
// 比较过期时间与当前系统时间
$currentTimestamp = time();
$expirationTimestamp = strtotime($expirationTime);
if ($expirationTimestamp > $currentTimestamp) {
    echo "未过期";
} else {
    echo "<script>alert('已经过期,过期时间为:{$expirationTime}');</script>";
}
?>



执行原理:

从通过客户公司名称在【****************】这个页面进行查询,并在返回结果里面提取到期时间,然后和系统当前时间进行对比;