Solved

GetLocalTime function in VC++

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
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 how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
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.

770 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