Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

GetLocalTime function in VC++

Posted on 2001-09-16
3
Medium Priority
?
700 Views
Last Modified: 2010-08-05
Hello all -

I was wondering how to implement the GetLocalTime function in VC++.  I looked at Microsoft documentation and cannont understand it.  Can someone give me an example snippet where I can pull the hour and minutes? Maybe AM or PM?  Is it in int array format?

Thank you for trying to help
0
Comment
Question by:salibes
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
mnashadka earned 440 total points
ID: 6486007
 SYSTEMTIME st;
  GetLocalTime(&st);
  cout << st.wHour << ":" << st.wMinute << " " << am_pm << endl;


You can use the fact that  wHour is > 12 to determine the AM/PM stuff.  Hope this helps.
0
 
LVL 1

Expert Comment

by:kuchnaheen
ID: 6486051
the better way is to use the following combintion

 GetLocalTime(&st)
   GetDateFormat(0,DATE_SHORTDATE,&st,NULL,date,sizeof(date));
   GetTimeFormat(0,LOCALE_NOUSEROVERRIDE,&st,NULL,time,sizeof(time));

where date and time r string buffers.....
0
 
LVL 1

Expert Comment

by:kuchnaheen
ID: 6486054
it will be rewarding if u can give some time to the formating options the later two functions offer...
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question