Reputation: 481
I am trying to get the time -24 hours ago using this:
$a = date('Y-m-d H:i:s', strtotime('-1 day', strtotime(date("Y-m-d H:i:s"))));
$a = strtotime($a);
which calculates fine, but when I use the variable $a
to send to an API, it says that the value is not an integer. The error returned is:
400 Invalid 'Query' parameter: json: cannot unmarshal number into Go struct field SearchClause.ClauseChildren.RuleValue of type string
If I change the variable to this: $a = '1583751712';
and send it to the API, it works absolutely fine.
Upvotes: 0
Views: 361
Reputation: 1602
The error occurs because your API
requires a string
and not an integer
. The function strtotime
returns the timestamp as integer
. Try to typecast
your integer to a string. Like Sherif
wrote before, you don't need the date formatting if you only need to return your timestamp.
$a = (string) strtotime('-1 day');
Upvotes: 2