Solved

GetLocalTime function in VC++

Posted on 2001-09-16
3
662 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 110 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
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.

740 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