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

  • Home
  • SEARCH
  • 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 8175565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:49:47+00:00 2026-06-06T22:49:47+00:00

I am capturing some events in a C# program that come back with the

  • 0

I am capturing some events in a C# program that come back with the timestamp as a system tickcount (milliseconds since start time).

Knowing, based on other questions I’ve seen, that I can get the same number from System.Environment.TickCount property (or something else), how can I infer the DateTime object that corresponds to the TickCount I received?

  • 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-06T22:49:51+00:00Added an answer on June 6, 2026 at 10:49 pm

    You can’t, without more information (and even then it can be ambiguous). Environment.TickCount returns:

    A 32-bit signed integer containing the amount of time in milliseconds that has passed since the last time the computer was started.

    … so unless you can find out the time the computer was started from somewhere, you’re out of luck. There may well be registry entries or system calls you can make to find out the last boot time, but I don’t know them off the top of my head. Of course, you can get an approximate value by taking Environment.TickCount yourself and DateTime.UtcNow as soon after (or before) that as possible, and finding the difference between the two:

    public static DateTime UnreliableDateTimeFromTickCount(int tickCount)
    {
        DateTime now = DateTime.UtcNow;
        DateTime boot = now - TimeSpan.FromMilliseconds(Environment.TickCount);
        return boot + TimeSpan.FromMilliseconds(tickCount);
    }
    

    However, even with that, the value will cycle round every 24.9 days, so if the computer has been on for longer than that, the count is ambiguous.

    I’d suggest avoiding using Environment.TickCount if possible, basically – is this under your control at all?

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

Sidebar

Related Questions

I've got a phone system that's reporting to me real time when a user
I am facing some issue while developing Video capturing application. 1) When I start
For IE7 and IE8, I am capturing some JSONp to use in my webpage.
I need some way of capturing the text between square brackets. So for example,
I'd like to log some contextual information when tests fail (like capturing screenshots). Is
my app involves some work with the camera, therefore it needs to handle capturing
when capturing events in the Automation event editor of Instruments (with the neat record
I am building a customer-facing website that requires me to build 1) some analytics
I am capturing some points on an X, Y plane to represent some values.
We have an ASP.NET application that queues some of its long-running operations (generating reports,

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.