1

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!

cpcdev
  • 1,130
  • 3
  • 18
  • 45

1 Answers1

0

You should provide the original Timezone and convert it to your Timezone.

See this Stackoverflow question and answer.

Convert time and date from one time zone to another in PHP

Good luck.

  • thanks, do you know what timezone it is in? the rest api timestamp that is – cpcdev Sep 23 '18 at 05:49
  • 1
    You should provide some actual code. Link-only answers are not very good. If you feel this question is a duplicate of the other, I recommend you flag it as a duplicate of the other question when you have more reputation points, or simply write it as a comment under the question. – Mike Sep 23 '18 at 06:00
  • Noted. Thanks @Mike – Rod Staines Sep 23 '18 at 06:02