I'm using the Bittrex REST API to find trades that occurred less than ten minutes ago:
https://bittrex.com/api/v1.1/public/getmarkethistory?market=BTC-ETH
Here are some of the trade timestamps that are returned from the endpoint:
2018-09-23T04:47:07.237
2018-09-23T04:47:02.797
Although today is actually 2018-09-22 where I live, it's showing these trades occurring in the future. Is the timezone different or something for these timestamps?
$now = date('m/d/y g:i a');
$now = strtotime($now);
$ten_minutes_ago = strtotime('-10 minutes');
foreach ($buy_sell_bittrex_orders['result'] as $buy_sell_bittrex_order) {
$buy_sell_bittrex_order_timestamp = $buy_sell_bittrex_order['TimeStamp'];
echo "Ten Minutes ago: " . $ten_minutes_ago . "<br>";
echo "Buy sell timestamp: " . $buy_sell_bittrex_order_timestamp . "<br>";
echo "Now: " . $now . "<br><br>";
if ( strtotime($buy_sell_bittrex_order_timestamp) >= $ten_minutes_ago && strtotime($buy_sell_bittrex_order_timestamp) <= $now ) {
// Do something
}
}
When I use the code above, none of the trades are found within 10 minutes ago, although there certainly must be. There can't have been trades that occurred in the future, so is there a timestamp issue here?
Here's an example of what the code above outputs:
Ten Minutes ago Bittrex: 1537679309
Buy sell timestamp: 1537704500
Now: 1537679940
In the example above, "Buy sell timestamp" is a higher value than "now" which represents the current day/time.
How can I convert the trade timestamps to match my current timezone? That seems to be the issue, though I may be wrong. Thanks!