Solved

GetLocalTime function in VC++

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
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 member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now