Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your help!

We need 7 developers from Canada and 18 more from Australia to help us complete a research survey.

Support our site by taking a quick sponsored survey and win a chance at a $50 Amazon gift card. Click here to get started!


C# XNA: How Do I get the Current Time in Milliseconds


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 jdub   Members   -  Reputation: 459

Like
0Likes
Like

Posted 25 March 2008 - 12:52 PM

I'm making a game in C# using XNA and I was wondering how you retrieve the current Time in Milliseconds. DateTime.Now.Millisecond isn't working for me as it doesn't return the full date in milliseconds.

Sponsor:

#2 TheUnbeliever   Members   -  Reputation: 962

Like
0Likes
Like

Posted 25 March 2008 - 01:11 PM

Milliseconds from when? The beginning of the year 1AD?

#3 Trillian   Members   -  Reputation: 410

Like
0Likes
Like

Posted 25 March 2008 - 01:42 PM

For game programming purposes, DateTime.Now.Ticks should be of interest to you. (If you need miliseconds, just divide that number by 10000, if I'm not mistaking).

Quote:
From MSDN:
A single tick represents one hundred nanoseconds or one ten-millionth of a second. 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.


#4 Chaotic_Attractor   Members   -  Reputation: 152

Like
0Likes
Like

Posted 25 March 2008 - 01:53 PM

System.Environment.TickCount will give you the number of milliseconds that have elapsed since the start of the application.

#5 typedef struct   Members   -  Reputation: 234

Like
0Likes
Like

Posted 25 March 2008 - 04:44 PM

GameTime.TotalGameTime.TotalMilliseconds is the milliseconds since the game started.

GameTime.ElapsedGameTime.TotalMilliseconds is the milliseconds since the last frame.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS