You didn't show any code, but you tagged your question as c#, so I will answer from that perspective.
If you just need to make sure you're talking about the same moment in time, then use a DateTime
with .Kind = DateTimeKind.Utc
, such as is obtained from DateTime.UtcNow
.
If you actually need to know that PC1 thought it was one time while PC2 thought it was another, and you still want to know that those two things represent the same moment in time, then use a DateTimeOffset
. This will include the local date and time of the computer, as well as the offset from UTC that the date and time represent.
With either approach, you should use the ISO8601 format for transport and persistence, so that your meaning is clear regardless of culture or time zone of the observer. In .Net, this is obtained with .ToString("o")
from either a DateTime
or DateTimeOffset
.
A UTC DateTime
in ISO8601 format would look like this:
2013-03-06T09:00:00Z
A DateTimeOffset
in ISO8601 format would look like this:
2013-03-06T10:00:00+01:00
.Net calls this the Round Trip pattern - because it is designed for the exact purpose you described.
For further clarification on DateTimeOffset
- see this post.