Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7819261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:52:12+00:00 2026-06-02T06:52:12+00:00

How come the following code (in C#) returns false : DateTime d = DateTime.Now;

  • 0

How come the following code (in C#) returns false :

DateTime d = DateTime.Now;
d.Ticks == d.ToUniversalTime().Ticks; // false

I’d expect the ticks of a DateTime to be based on UTC time.
The MSDN page on DateTime.Ticks mentions says

The value of this property represents the number of 100-nanosecond intervals that have elapsed since 12:00:00 midnight, January 1, 0001, which represents DateTime.MinValue. It does not include the number of ticks that are attributable to leap seconds.

Midnight on January first, 0001 .. in which timezone ?

Why would DateTime.Ticks be timezone dependant ?

I guess that the fact that the Ticks are different is why the following code also returns false

DateTime d = DateTime.Now;
d == d.ToUniversalTime(); // false

The MSDN doc on DateTime.Equals mentions

t1 and t2 are equal if their Ticks property values are equal. Their Kind property values are not considered in the test for equality.

My expectation was that DateTime.Ticks would be equal, no matter the timezone.

I’d expect two moments in time to be equal no matter on what timezone they happened. Are my expectations wrong ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T06:52:18+00:00Added an answer on June 2, 2026 at 6:52 am

    source: http://social.msdn.microsoft.com/Forums/en/netfxbcl/thread/fde7e5b0-e2b9-4d3b-8a63-c2ae75e316d8

    DateTime.Ticks is documented as “number of 100-nanosecond intervals
    that have elapsed since 12:00:00 midnight, January 1, 0001”. That is
    1-Jan-0001 local time. If you convert your DateTime to UTC, Ticks
    will then be number of 100-nanosecond intervals that have elapsed
    since 12:00:00 midnight, January 1, 0001 UTC. Potentially different
    that 1-Jan-0001 local time, ergo the two Ticks values will be
    different.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Why the following code will return obvious , surprise! (and lastly how come? ).
I've just come across the following code: #include <iostream> static class Foo { public:
I have come across the following jQuery code but could not understand it. What
I have come up with the following code to call a webservice using client/server
I've come across an odd problem with the following code: $image = new Imagick($real_location);
I have come across the following type of code many a times, and I
I have come across the following link: http://code.google.com/p/a-star/source/browse/trunk/java/PathFinder.java?r=8 I have got the code working
Frequently I come across the following statements in C/C++ source code: $Id: lzio.c,v 1.24
I've come across an interesting problem in the following line of code: <img style=background-image:url(Resources/bar.png);
I'm currently refactoring code to replace Convert.To's to TryParse. I've come across the following

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.