How to check if UNIXTimeStamp is average day or evening in php
I have a JSON response that contains a DateTime in UNIXTIMESTAMP. I would like to find that the time in the JSON Response is an average day or evening.
Let's say below the answer and I want to check if the weather in CloseTime is daytime or evening.
{
"gameName": "NUMBERS",
"id": "16440",
"status": "RESULTS_AVAILABLE",
"closeTime": "1491927615000"
}
+3
source to share
1 answer
This might work for you. Make json code and assign closeTime to $ timestamp
<?php
$timestamp = 1491927615000;
$date = date('H', $timestamp);
if($date < 12){
echo "good morning";
}elseif($date > 11 && $date < 18){
echo "good afternoon";
}elseif($date > 17){
echo "good evening";
}
?>
+1
source to share