Jump to content

  • Log In with Google      Sign In   
  • Create Account

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   Members   

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.

#2   Members   

962
Like
0Likes
Like

Posted 25 March 2008 - 01:11 PM

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

#3   Members   

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   Members   

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   Members   

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.