public sealed class DateTime : IMessage<DateTime>, IEquatable<DateTime>, IDeepCloneable<DateTime>, IBufferMessage, IMessage
Represents civil time (or occasionally physical time).
This type can represent a civil time in one of a few possible ways:
When utc_offset is set and time_zone is unset: a civil time on a calendar
day with a particular offset from UTC.
When time_zone is set and utc_offset is unset: a civil time on a calendar
day in a particular time zone.
When neither time_zone nor utc_offset is set: a civil time on a calendar
day in local time.
The date is relative to the Proleptic Gregorian Calendar.
If year is 0, the DateTime is considered not to have a specific year. month
and day must have valid, non-zero values.
This type may also be used to represent a physical time if all the date and
time fields are set and either case of the time_offset oneof is set.
Consider using Timestamp message for physical time instead. If your use
case also would like to store the user's timezone, that can be done in
another field.
This type is more flexible than some applications may want. Make sure to
document and validate your application's limitations.
Required. Hours of day in 24 hour format. Should be from 0 to 23. An API
may choose to allow the value "24:00:00" for scenarios like business
closing time.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eDateTime\u003c/code\u003e class represents civil time, which can be defined by a UTC offset, a time zone, or local time, and is relative to the Proleptic Gregorian Calendar.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eDateTime\u003c/code\u003e objects can be used to represent physical time if all date and time fields are set, but the \u003ccode\u003eTimestamp\u003c/code\u003e message is preferred for physical time representations.\u003c/p\u003e\n"],["\u003cp\u003eThe class provides constructors for creating \u003ccode\u003eDateTime\u003c/code\u003e instances, including a copy constructor, and has various fields like \u003ccode\u003eYear\u003c/code\u003e, \u003ccode\u003eMonth\u003c/code\u003e, \u003ccode\u003eDay\u003c/code\u003e, \u003ccode\u003eHours\u003c/code\u003e, \u003ccode\u003eMinutes\u003c/code\u003e, \u003ccode\u003eSeconds\u003c/code\u003e, \u003ccode\u003eNanos\u003c/code\u003e, \u003ccode\u003eTimeZone\u003c/code\u003e, and \u003ccode\u003eUtcOffset\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eIt implements interfaces such as \u003ccode\u003eIMessage\u003c/code\u003e, \u003ccode\u003eIEquatable<DateTime>\u003c/code\u003e, \u003ccode\u003eIDeepCloneable<DateTime>\u003c/code\u003e, and \u003ccode\u003eIBufferMessage\u003c/code\u003e, offering methods for cloning, equality checks, and data handling.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eDateTime\u003c/code\u003e class also allows for the specification of a time zone or a UTC offset to define a specific time relative to UTC, and can be used without a specified year.\u003c/p\u003e\n"]]],[],null,["# Class DateTime (2.17.0)\n\nVersion latestkeyboard_arrow_down\n\n- [2.17.0 (latest)](/dotnet/docs/reference/Google.Api.CommonProtos/latest/Google.Type.DateTime)\n- [2.15.0](/dotnet/docs/reference/Google.Api.CommonProtos/2.15.0/Google.Type.DateTime)\n- [2.10.0](/dotnet/docs/reference/Google.Api.CommonProtos/2.10.0/Google.Type.DateTime)\n- [2.2.0](/dotnet/docs/reference/Google.Api.CommonProtos/2.2.0/Google.Type.DateTime) \n\n public sealed class DateTime : IMessage\u003cDateTime\u003e, IEquatable\u003cDateTime\u003e, IDeepCloneable\u003cDateTime\u003e, IBufferMessage, IMessage\n\nRepresents civil time (or occasionally physical time).\n\nThis type can represent a civil time in one of a few possible ways:\n\n- When utc_offset is set and time_zone is unset: a civil time on a calendar day with a particular offset from UTC.\n- When time_zone is set and utc_offset is unset: a civil time on a calendar day in a particular time zone.\n- When neither time_zone nor utc_offset is set: a civil time on a calendar day in local time.\n\nThe date is relative to the Proleptic Gregorian Calendar.\n\nIf year is 0, the DateTime is considered not to have a specific year. month\nand day must have valid, non-zero values.\n\nThis type may also be used to represent a physical time if all the date and\ntime fields are set and either case of the `time_offset` oneof is set.\nConsider using `Timestamp` message for physical time instead. If your use\ncase also would like to store the user's timezone, that can be done in\nanother field.\n\nThis type is more flexible than some applications may want. Make sure to\ndocument and validate your application's limitations. \n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e DateTime \n\nImplements\n----------\n\n[IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage-1.html)[DateTime](/dotnet/docs/reference/Google.Api.CommonProtos/latest/Google.Type.DateTime), [IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[DateTime](/dotnet/docs/reference/Google.Api.CommonProtos/latest/Google.Type.DateTime), [IDeepCloneable](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IDeepCloneable-1.html)[DateTime](/dotnet/docs/reference/Google.Api.CommonProtos/latest/Google.Type.DateTime), [IBufferMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IBufferMessage.html), [IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage.html) \n\nInherited Members\n-----------------\n\n[object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)) \n[object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) \n[object.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals)\n\nNamespace\n---------\n\n[Google.Type](/dotnet/docs/reference/Google.Api.CommonProtos/latest/Google.Type)\n\nAssembly\n--------\n\nGoogle.Api.CommonProtos.dll\n\nConstructors\n------------\n\n### DateTime()\n\n public DateTime()\n\n### DateTime(DateTime)\n\n public DateTime(DateTime other)\n\nFields\n------\n\n### DayFieldNumber\n\n public const int DayFieldNumber = 3\n\nField number for the \"day\" field.\n\n### HoursFieldNumber\n\n public const int HoursFieldNumber = 4\n\nField number for the \"hours\" field.\n\n### MinutesFieldNumber\n\n public const int MinutesFieldNumber = 5\n\nField number for the \"minutes\" field.\n\n### MonthFieldNumber\n\n public const int MonthFieldNumber = 2\n\nField number for the \"month\" field.\n\n### NanosFieldNumber\n\n public const int NanosFieldNumber = 7\n\nField number for the \"nanos\" field.\n\n### SecondsFieldNumber\n\n public const int SecondsFieldNumber = 6\n\nField number for the \"seconds\" field.\n\n### TimeZoneFieldNumber\n\n public const int TimeZoneFieldNumber = 9\n\nField number for the \"time_zone\" field.\n\n### UtcOffsetFieldNumber\n\n public const int UtcOffsetFieldNumber = 8\n\nField number for the \"utc_offset\" field.\n\n### YearFieldNumber\n\n public const int YearFieldNumber = 1\n\nField number for the \"year\" field.\n\nProperties\n----------\n\n### Day\n\n public int Day { get; set; }\n\nRequired. Day of month. Must be from 1 to 31 and valid for the year and\nmonth.\n\n### Descriptor\n\n public static MessageDescriptor Descriptor { get; }\n\n### Hours\n\n public int Hours { get; set; }\n\nRequired. Hours of day in 24 hour format. Should be from 0 to 23. An API\nmay choose to allow the value \"24:00:00\" for scenarios like business\nclosing time.\n\n### Minutes\n\n public int Minutes { get; set; }\n\nRequired. Minutes of hour of day. Must be from 0 to 59.\n\n### Month\n\n public int Month { get; set; }\n\nRequired. Month of year. Must be from 1 to 12.\n\n### Nanos\n\n public int Nanos { get; set; }\n\nRequired. Fractions of seconds in nanoseconds. Must be from 0 to\n999,999,999.\n\n### Parser\n\n public static MessageParser\u003cDateTime\u003e Parser { get; }\n\n### Seconds\n\n public int Seconds { get; set; }\n\nRequired. Seconds of minutes of the time. Must normally be from 0 to 59. An\nAPI may allow the value 60 if it allows leap-seconds.\n\n### TimeOffsetCase\n\n public DateTime.TimeOffsetOneofCase TimeOffsetCase { get; }\n\n### TimeZone\n\n public TimeZone TimeZone { get; set; }\n\nTime zone.\n\n### UtcOffset\n\n public Duration UtcOffset { get; set; }\n\nUTC offset. Must be whole seconds, between -18 hours and +18 hours.\nFor example, a UTC offset of -4:00 would be represented as\n{ seconds: -14400 }.\n\n### Year\n\n public int Year { get; set; }\n\nOptional. Year of date. Must be from 1 to 9999, or 0 if specifying a\ndatetime without a year.\n\nMethods\n-------\n\n### CalculateSize()\n\n public int CalculateSize()\n\n### ClearTimeOffset()\n\n public void ClearTimeOffset()\n\n### Clone()\n\n public DateTime Clone()\n\n### Equals(DateTime)\n\n public bool Equals(DateTime other)\n\n### Equals(object)\n\n public override bool Equals(object other)\n\n**Overrides** \n[object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object))\n\n### GetHashCode()\n\n public override int GetHashCode()\n\n**Overrides** \n[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode)\n\n### MergeFrom(CodedInputStream)\n\n public void MergeFrom(CodedInputStream input)\n\n### MergeFrom(DateTime)\n\n public void MergeFrom(DateTime other)\n\n### ToString()\n\n public override string ToString()\n\n**Overrides** \n[object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)\n\n### WriteTo(CodedOutputStream)\n\n public void WriteTo(CodedOutputStream output)"]]