Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

da_cobra

how to get the system time

This topic is 6067 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I use the visual c++ and I have a structure : struct time {int hours ; int minutes ; int seconds ; } ; now how do I read the system time and put it into that structure I already found how to read the system time and put it into a string, but I need it in that srtucture, so I can acces the hours, minutes and seconds by themself thanx in advance

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Why not use the SYSTEMTIME structure:

SYSTEMTIME st;
GetSystemTime (&st);
cout << st.wHour << '':'' << st.wMinute << '':'' << st.wSecond;

Share this post


Link to post
Share on other sites
quote:
From MSDN:

GetSystemTime


This function retrieves the current system date and time. The system time is expressed in Coordinated Universal Time (UTC).


You need to find the offset of your timezone from UTC. As always, the full documentation can be found at MSDN.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
How about getting the localtime() instead of getting system time and converting it according to local timezone?

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!