Subtracting Departure time from current time

Hi guys,

So I am using the departure mon trip planner api. I am creating a departure screen and need the minutes until the bus departs. However when I go to get the departing buses it always gives me buses in the next day even though i put the current time in automatically. If someone could help me this would be greatly appreciated.
Cheers

import requests, json
import os
import time
from datetime import datetime
FMT = '%H:%M'
tdelta = ''
timedelta = ''
busNumbers = ''
serialTimes = ''
x = 1

while x is 1:
    tdelta = ''
    timedelta = ''
    busNumbers = ''
    serialTimes = ''
    str(busNumbers)
    url = 'https://api.transport.nsw.gov.au/v1/tp/departure_mon?outputFormat=rapidJSON&coordOutputFormat=EPSG%3A4326&mode=direct&type_dm=stop&name_dm=10101161&itdDate='
    ctime = time.strftime('%H%M')
    print(ctime)
    url2 = '&itdTime='
    cdate = time.strftime("%Y%m%d")
    url3 = '&departureMonitorMacro=true&TfNSWDM=true&version=10.2.1.42'
    finalUrl = url + cdate + url2 + ctime + url3
    print(finalUrl)
    payload = ''

    headers = {'content-type': 'application/json', 'Accept-Charset': 'UTF-8', 'Authorization': 'apikey Omrk9Cxef4tet4Jc5NsdGgcgZjqFLzTiUYvF' }
    r = requests.get(finalUrl, data=payload, headers=headers).json()

    for buses in r['stopEvents'][0:6]:
        busNumbers = busNumbers + (buses['transportation']['disassembledName']) + ' '
    print(busNumbers)

    for times in r['stopEvents'][0:6]:
        timesTD = (times['departureTimePlanned'][11:16])
        print(timesTD)
        datetime.strptime(timesTD, '%H:%M')
        realtime = time.strftime("%H:%M")
        tdelta = datetime.strptime(timesTD, FMT) - datetime.strptime(realtime, FMT)
        tdelta = str(tdelta)
        print(tdelta[11:13])
    time.sleep(60)

Hi @Bobby_Dazzler, the time returned is in UTC, you just need to convert it to local time.

Thanks,
Alex

Perfect. Cheers