Nate
Nate

Reputation: 2326

Creating a date range that has a total UTC day

I'm trying to create a time bucket for a query that includes all times for a specific day anywhere where in the world.

I'm having problems getting my base "UTC" time to do my calculations.

I have:

var baseDate = new DateTime(2013, 1, 17);

var minDate = baseDate.AddHours(-12);
var maxDate = baseDate.AddHours(14);

This is wrong, as the new DateTime takes into account my local time zone and not 12 AM UTC on Janurary 17th, 2013.

How do I get baseDate to be 12am UTC on Janurary 17th, 2013?

Upvotes: 2

Views: 104

Answers (1)

AD.Net
AD.Net

Reputation: 13399

new DateTime(2013, 1, 17, 0,0,0, DateTimeKind.Utc)

Upvotes: 7

Related Questions