我希望今天的timestamp
等于3
或小于3
,如果不返回FALSE,则返回TRUE
我将时间戳转换为日期格式并过滤当前日期时间戳
我的数组:
Array
(
[timestamp] => 1570819492
)
Array
(
[timestamp] => 1570819505
)
Array
(
[timestamp] => 1570819516
)
Array
(
[timestamp] => 1570819525
)
Array
(
[timestamp] => 1570819536
)
Array
(
[timestamp] => 1532963273
)
代码在这里,但是没有用:
foreach ($items as $Newarrays) {
$timestamp=$Newarrays[timestamp];
$accessdate=format_date($timestamp, 'custom', 'd-m-Y' );
$currentdate=date("d-m-Y");
if ($accessdate === $currentdate) {
if (count($timestamp) > 3) {
return FALSE;
} else {
return TRUE;
}
}
我认为您必须尝试一下:
// let's suppose you array seems to be like the array bellow :
$items = [
["timestamp"=>"1570819492"],
["timestamp"=>"1570819505"],
["timestamp"=>"1570819516"],
["timestamp"=>"1570819525"],
["timestamp"=>"1570819536"]
];
foreach ($items as $Newarrays) {
$timestamp=$Newarrays["timestamp"];
$accessdate=date('d-m-Y',$timestamp );
$currentdate=date("d-m-Y");
if ($accessdate === $currentdate) {
if (count($timestamp) > 3) {
return false;
} else {
return true;
}
}
}