Monday, 5 October 2009

ConvertTimeFromUtc - Market Start Times

I was having problems with the start time of my markets being an hour slower than the times on the Betfair website, before I realised that daylight saving time might have something to do with it. Here's a nice line of code that converts the UTC Market start time to the local time (I put it inside the function that populates my user interface from a MarketSummary[]):

currentMarketSummary.startTime = TimeZoneInfo.ConvertTimeFromUtc(currentMarketSummary.startTime, TimeZoneInfo.Local);

Where currentMarketSummary is an object of type MarketSummary.

This will convert the time returned by Betfair into your local time. These things seem simple once they're working correctly..!

No comments:

Post a Comment