-4
I have a JSON obtained from an API that returns a list of events like this:
Array
(
[alertList] => Array
(
[alerts] => Array
(
[0] => Array
(
[id] => 145392039
[name] => Failed Zonetransfer
[type] => Failed Zonetransfer (Critical)
[startDate] => Aug 22, 2016 10:24 AM
[errorString] =>
)
)
[errorString] =>
)
)
I use strtotime
in the Indian startDate
to format it to timestamp.
How can I check if the event is from today?
I thought I’d compare it to the present day, picking up the timestamp at 12:00, but it didn’t work:
$date = new DateTime();
//$date->add(new DateInterval('PT1D')); essa linha tem erro, o parametro creio eu
$timestamp = ($date->getTimestamp()*1000);
echo $timestamp.PHP_EOL;exit;
Post a return model.
– Celso Marigo Jr
Array ( [alertList] => Array ( [Alerts] => Array ( [0] => Array ( [id] => 145392039 [name] => Failed Zonetransfer [type] => Failed Zonetransfer (Critical) [startDate] => Aug 22, 2016 10:24 AM [errorString] => ) ) [errorString] => ) ) I give strtotime in startDate Indice to format for timestamp
– Daniel Vieira Junior
I just need to know, is it today, day 22? the time I believe start at 00:00
– Daniel Vieira Junior
Or I needed to pick up today’s timestamp at 00:00 am I’m already using it: $date = new Datetime(); //$date->add(new Dateinterval('PT1D')); this line has error, the parameter believe me $timestamp = ($date->getTimestamp()*1000); echo $timestamp.PHP_EOL;Exit; I’m multiplying by 1000 pq is in milliseconds.
– Daniel Vieira Junior
Daniel please put the Json return format and a minimum of code so we know what you have already done.
– Guilherme Nascimento