Solved

GetLocalTime function in VC++

Posted on 2001-09-16
3
672 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

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…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

630 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