I have a UTC DateTime value: 12:00 midnight, January 1, 1601 A.D. (C.E.), UTC
How would I hardcode this UTC DateTime value in C#
if (job.DateTimeValue == <UTC value>)
I have a UTC DateTime value: 12:00 midnight, January 1, 1601 A.D. (C.E.), UTC
How would I hardcode this UTC DateTime value in C#
if (job.DateTimeValue == <UTC value>)
The DateTime
type has a constructor that allows you to set:
Year
Month
Day
Hour
Minute
Second
Millisecond
DateTimeKind
(UTC, Local, Unspecified)var jobMinDateValue = new DateTime(1601, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
if (job.DateTimeValue == jobMinDateValue)
{
// ...
}
12:00 midnight, January 1, 1601 A.D. (C.E.), UTC happens to be a special date & time on Windows... Windows represents FileTime
as the number of 100-nanosecond intervals that have elapsed since 12:00 midnight, January 1, 1601 A.D. (C.E.) Coordinated Universal Time (UTC).
That means that in FileTime
terms the value 0
means 12:00 midnight, January 1, 1601 A.D. (C.E.), UTC
That gives you another alternative to get the same value you're looking for:
var jobMinDateValue = DateTime.FromFileTimeUtc(0);
if (job.DateTimeValue == jobMinDateValue)
{
// ...
}