gpt4 book ai didi

php - 日期比较 PHP Mysql

转载 作者:行者123 更新时间:2023-11-29 01:23:46 25 4
gpt4 key购买 nike

我有一个系统正在将 mysql 表格日期与今天的日期进行比较,以查看某个文档是否需要更新:

<?php
$student_id = $row_student['student_id'];

$query_ieps = mysql_query("SELECT * FROM `iep` WHERE student_id = ".$student_id."") or die(mysql_error());

$iep_count = mysql_num_rows($query_ieps);

$row_iep = mysql_fetch_assoc($query_ieps);

$today = date("d-m-Y");

$iep_date = $row_iep['iep_renewal'];

$convert_iep_date = date("d-m-Y", strtotime($iep_date));

$redate_coverted_date = $convert_iep_date;

if($iep_count == 0){ $iep_status = "No IEP on record"; $iep_td_status = "grey-alert"; }
elseif($today <= $redate_coverted_date) { $iep_status = "Due for Renewal"; $iep_td_status = "mid-alert"; }
elseif($today >= $redate_coverted_date) { $iep_status = "Up to Date"; $iep_td_status = "green-alert"; };
?>

我有两组值:

id: 1 -> iep_renewal: 12-02-2012

id: 2 -> iep_renewal: 12-08-2012

然而,当第一个显然不是时,表格输出这两个值都是“最新的”。

有没有办法做到这一点,如果有,怎么做!

最佳答案

$some_date_timestamp = strtotime('18-02-2011');

$current_timestamp = time();

echo ($some_date_timestamp < $current_timestamp) ? 'Old date' : 'Future date';

关于php - 日期比较 PHP Mysql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9353384/

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