[英]how to check given date time is before current date time or not with php
I have date-time formate like Thu, 30 Mar 2028 04:00:00 GMT
and I want to check given date-time is before current date-time or not with PHP我有日期时间格式,例如
Thu, 30 Mar 2028 04:00:00 GMT
,我想检查给定的日期时间是否在当前日期时间之前使用 PHP
for that I have use为此我使用
function status($expire_date){
date_default_timezone_set("Asia/Kolkata");
$current_date = date("Y-m-d H:i:s");
$valid = date_create($expire_date);
$ex_date = date_format($valid,"Y-m-d H:i:s");
//echo $ex_date; die();
if ($ex_date <= $current_date) {
$status = 'Yes';
}else{
$status = 'No';
}
return $status;
}
$status = status($expire_date);
if($status == 'Yes'){
$expire_domain_array[] = $row;
}
but when I make this expire_domain_array it gives me the wrong result I don't know why this is happening但是当我做这个 expire_domain_array 它给了我错误的结果我不知道为什么会这样
can anybody help me with this谁能帮我这个
You can use strtotime
function to do that:您可以使用
strtotime
函数来做到这一点:
function isExpired($expire_date){
return strtotime($expire_date) < strtotime('now');
}
// Check if expired
if(isExpired($expire_date)){
echo 'expired';
} else {
echo 'not expired';
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.