Getting local Time and date for the local computer(vista OS)

Hi I am working with Vista(one of a kind),
and have a MFC application and would like to add small code that  will get 
current time and date from the local compuetr.
i meet an example in MSDN :
http://msdn.microsoft.com/en-us/library/aa390423(VS.85).aspx
but it looks too long for what i am looking, is there a 1 function API that 
returns the Date and the time ?

thanks for your time 
Zack
0
zack1 (34)
12/14/2008 10:16:02 AM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
824 Views

Similar Articles

[PageSpeed] 28

>Hi I am working with Vista(one of a kind),
>and have a MFC application and would like to add small code that  will get 
>current time and date from the local compuetr.
>i meet an example in MSDN :
>http://msdn.microsoft.com/en-us/library/aa390423(VS.85).aspx
>but it looks too long for what i am looking, is there a 1 function API that 
>returns the Date and the time ?

Zack,

Have a look at the GetSystemTime (or GetLocalTime) API.

Dave
0
davidl7375 (2060)
12/14/2008 12:58:05 PM
Thanks David,
this is the code is working for me:

CTime t = CTime::GetCurrentTime();

hour = t.GetHour() ;
minutes = t.GetMinute();
month = t.GetMonth();
day = t.GetDayOfWeek();
year = t.GetYear();

"David Lowndes" wrote:

> >Hi I am working with Vista(one of a kind),
> >and have a MFC application and would like to add small code that  will get 
> >current time and date from the local compuetr.
> >i meet an example in MSDN :
> >http://msdn.microsoft.com/en-us/library/aa390423(VS.85).aspx
> >but it looks too long for what i am looking, is there a 1 function API that 
> >returns the Date and the time ?
> 
> Zack,
> 
> Have a look at the GetSystemTime (or GetLocalTime) API.
> 
> Dave
> 
0
zack1 (34)
12/14/2008 2:16:03 PM
Reply:

Similar Artilces:

Time Series
I have about 30000 lines of data that looks like so: Time Count 93000 447 93001 1020 93002 1438 93003 2177 93004 3042 93005 3467 93006 2913 93007 3341 93008 3547 93009 2908 93010 3512 93011 4090 Where ColA is time. I am having trouble creating a graph with time on the x-axis and count on the y-axis. Thank you in advance. You need to make an XY chart But with 30,000 data points you could run into trouble; Help says you can 32,000 data points in a single data series. However, if you want markers it will look like heck. You could limit the data like this: assume y-values in B2:B30001 in ...

Running Money 2003 in Vista
Hi I run this version perfectly satisfactorily in my Vista Ultimate desktop.with my normal log on. No fiddling was required to get it to start. It worked perfectly out of the box, just as in XP Referring to emails on earlier versions in the Newsgroup, my data is in a Documents folder on the D Drive well away from Vista, though it is secured. In this machine SSL2 is not enabled I have a newish laptop running Windows Home Premium with a similar configuration for all my data on the D drive. I recently tried to open Money for the first time since installation using a copy of the Money fil...

Date display in Excel
Format column of cells as Date, display as mm/dd/yy. Date entered into cell, shows up correctly in the text entry field at the top of the screen, but the data on the worksheet displays as "33747", or similar number. Only happening on one workbook. Try tools|options|View tab|uncheck Formulas. Clark wrote: > > Format column of cells as Date, display as mm/dd/yy. Date > entered into cell, shows up correctly in the text entry > field at the top of the screen, but the data on the > worksheet displays as "33747", or similar number. Only > happening on one...

How can I get 32-bit Integers?
I am using Access MS Office 2007 with VBA 6.5, on Win XP. My Integer type is just 16 bits, i.e. its max value is 32,767. How can I configure it so as to have 32-bit Integers, along with 64-bit Longs? "Renny Bosch" <noname@nospam.com> wrote in message news:OqqNyqmuKHA.4492@TK2MSFTNGP05.phx.gbl... > I am using Access MS Office 2007 with VBA 6.5, on Win XP. My Integer type > is just 16 bits, i.e. its max value is 32,767. How can I configure it so > as to have 32-bit Integers, along with 64-bit Longs? An Access Integer is 16 bits. A Long Integer is...

INTERNET MILLION DOLLARS
INTERNET MILLION DOLLARS - www.InternetMillionDollars.biz Watch the VIDEO on YOUTUBE... NOW! http://www.youtube.com/watch?v=dXQUjk5EGV0 MAKE MONEY INSTANTLY using 2007 featured INTERNET MILLION DOLLARS as a resource. WORK FROM HOME HOMEBASED JOBS AND IDEAS BUSINESS OPPORTUNITY Professor James Bradley's "Quick and real way to make BIG MONEY on the Internet!" The Independent Finally you have FOUND IT! Make a FORTUNE each month... .... every month! 100% ON AUTOPILOT Read it NOW and CHANGE YOUR LIFE! Are you fed up with being short of MONEY all the time? Do you DREAM about a...

How do I get Powerpoint 2003 fade in 1 by 1 in 2007
I frequently used the 'fade in one by one' feature in Powerpoint 2003, which allowed me to fade in individual bullet points by way of a click of a mouse. Not only is this feature now not standard in 2007, but I can't work out how to create it: anything that I find, tends, instead, to fade the bullet points in on some kind of automatic time schedule, rather than - as I want - on a mouse click. I want only to use text, no sounds, no pictures, and nothing fancy. Currently, I am reduced to copying my material into an old Powerpoint 2003 presentation, but this is silly....

OS version
Hi, I use GetVersionEx to check if the OS version is W95. This is the code I use: BOOL boW95 = FALSE; OSVERSIONINFOEX ovi; ZeroMemory(&ovi, sizeof(OSVERSIONINFOEX)); ovi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); if(!GetVersionEx((OSVERSIONINFO*)&ovi)) { ovi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx((OSVERSIONINFO*)&ovi); } if(ovi.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS && ovi.dwMajorVersion == 4 && ovi.dwMinorVersion == 0) { boW95 = TRUE; } I run that code and boW95 is set to TRUE on a PC with version XP. I tried on 2 machi...

C# Adding Days to a Date
Hello, I have 2 objects: objContract.activeon and objContract.expireson. I am trying to add 364 days to objContract.activeon and assign it to the value of objContractexpireson. ---------------------------------------------------------- // Contract Start Date DateTime dt = DateTime.Now; objContract.activeon = new CrmDateTime(); int iFound = 0; string sTemp = ""; if (objAccount.paymenttermscode.Value == 1) // due on receipt - use Todays Date { objContract.activeon = objInvoice.CFDinvoicedate; } else // ...

Separating Date and Time in a cell
I have a column of cells in the format "11/01/02 06:21". I would like to separate the text into 2 cells - one with the date and the other with the time. My attempts with LEFT and RIGHT have been unsuccesful. Thanks for your help Sameer --- Message posted from http://www.ExcelForum.com/ For the date use =INT(A1) replace A1 with the first cell of your range for time =MOD(A1,1) you probably have to reformat the first to mm/dd/yy (or whatever the setting is) and hh:mm Note that you can do this by just using format but if you want to compare to other cells with just pure d...

getting started
I'm installing office 2003, outlook, I'm lost from server type to URL address to server info? I have sbc yahoo dsl. can you help me? damselindistress <damselindistress@discussions.microsoft.com> wrote: > I'm installing office 2003, outlook, I'm lost from server type to URL > address to server info? I have sbc yahoo dsl. can you help me? When you obtained your packet from SBC, they included all that information. Moreover, it's in the Help section of SBC Yahoo's site. The most likely settings are "pop.sbcglobal.yahoo.com" for the incoming serv...

how do you get a landscape page?
Please help, desperate! If you are using 2010, Page Design tab, Size, More pre-set page sizes. Letter landscape is the first choice. In all other Publisher versions landscape will be on the page setup screen found in the File menu. -- Mary Sauer http://msauer.mvps.org/ "becky.x" <becky.x@discussions.microsoft.com> wrote in message news:25D3EDBC-93EF-4582-94B2-83C9CE121E17@microsoft.com... > Please help, desperate! ...

Run time error 5 : HQClient
When I double click HQ Client I have message box "Run time error 5 : Invalid procedure call or argument" how should I do? I used RMS 2.0 -- TOY2TOY ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-based Newsreader and then click "I Agree" in the message pane. http://www.microsoft.com/Businesssolutions/Community/NewsGr...

date function #3
This is a multi-part message in MIME format. ------=_NextPart_000_0006_01C73005.0FA093A0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I have a cell A1 with date 5/2/07. If in cell A2 I do month(A1), I get = 5. Is there a way to return May instead? either through a command or = formatting? I can reference cell A2 with the 5 with a if(cell =3D 5, = "May", ) in cell A3, but the date in cell A1 varies from Jan to Dec and = the 12 embedded if's in cell A3 are too long (that is the error I get = when trying to do so), plus i...

Setting appointment start & end time increments format
In Outlook 2002, I can easily set the Day View to display the time increments in 15 minute blocks, but on the Appointments form, the Start and End Times available on the drop-down menus, respectively, are in 30 minute increment blocks only. How can I set the format for the appointment page to have the Start and End Times for appointments have increment time blocks of 15 minutes? Thanks! My direct email address is: solutioncounselor@comcast.net . If you set your appointments in 15 minute blocks Outlook will start to offer that. It takes a few uses to work. -- Nikki Peterson [MVP ...

Time Format Question
Hello, I currently have time entered like this: 173517 90207 I need to look like this: 5:35 p.m. 9:02 a.m. I've done a ton of research but nothing has worked so far. Thank you. With your values in column AA, try: =TIME(LEFT(A1,LEN(A1)-4),LEFT(RIGHT(A1,4),2),RIGHT(A1,2)) -- Gary''s Student - gsnu201003 "Toria" wrote: > Hello, > I currently have time entered like this: > 173517 > 90207 > > I need to look like this: > 5:35 p.m. > 9:02 a.m. > > I've done a ton of research but nothing has worked so fa...

how do I change date format in the header in Excel XP ?
I need to chage my date format, in the header to Day; Month DD, YYYY ie. Saturday; May 23, 2005. Woudl you please help me out ? Thank you. Regards, Hesam Shakourian Check this out. http://support.microsoft.com/?kbid=213742 but change the format to "dddd, MMMM dd, yyyy" "Hesam" <Hesam@discussions.microsoft.com> wrote in message news:93495F75-4196-4208-9C0D-E800BCAE3A89@microsoft.com... > I need to chage my date format, in the header to Day; Month DD, YYYY > ie. Saturday; May 23, 2005. > > Woudl you please help me out ? > > Thank you. > &g...

Vista cant rest/hibernate
Xp can be stopped with Waiting or Resting/Hibernating (Dont have an english one). Our Vista Home have only Resting but it works like Waiting in XP, it starts at a touch, we like to have it resting. Is there no such function or what can be wrong? ...

calendar for multiple time zone users: all day events
Users in different time zones post absences and meetings to a shared company calendar. When an all day event is scheduled in one time zone, it shows as spanning two days for other time zone users. How do we make this work properly? For the others it does intrude on a second day. BossLady wrote: > Users in different time zones post absences and meetings to a shared company > calendar. When an all day event is scheduled in one time zone, it shows as > spanning two days for other time zone users. How do we make this work > properly? Until you upgrade to Outlook...

Times
I have an MP3 tag program that exports a list of my MP3's to excel which includes the time for each song. The cell format in the exported file is set to general but I need to have the time entered as [m]:ss so I can total a the time for a number of songs in a cell (with a [h]:mm:ss format) to get a total time which may be over 1 hour. The only way I can seem to do this is by changing the cell format from general to [m]:ss and placing a 0: in front of the time that has already been entered as 04:39, but with over 2000 songs this could take quite a while. Does anyone know if there is an easy...

Option trades with past expiry dates not showing up in Portfolio M
Hello: Money 2006 Portfolio Manager does not show closed option trades that have expiry dates in the past, even when the "show closed positions" is checked. The transactions are still there in the investment accounts, just not visible in portfolio manager. I just called microsoft support and have notified them of the issue and hope that this issue is fixed as an update. If not, it pretty much makes the portfolio manager (and Microsoft Money 2006) useless for option trading investors. "MumbaiBabu" <MumbaiBabu@discussions.microsoft.com> wrote in message news:1...

How do you sort a date range by month?
We are trying to find out how many birthdays fall with in a given month using excel. You could use a helper column, with something like = A2. Format this (Format - Cells - Number - Custom: mmm. Now you can use Data - Subtotals, "At each change in: Month" and "Use function: Count." -- Earl Kiosterud www.smokeylake.com/ ------------------------------------------- "Brewisc13" <Brewisc13@discussions.microsoft.com> wrote in message news:44E02AAC-8216-43F5-846F-E981E978E44B@microsoft.com... > We are trying to find out how many birthdays fall with in...

plotting time
What is the best way to plot time series data? For instance, I have plotted columns of data against time using "X-Y (Scatter)" chart instead of "line" chart. Is one preferred over the other? Also, when adding additional data to the chart, I can use "Chart->Add Data", or I can simply copy a column and use "Paste Special" to paste it into the chart. Is there no difference between the methods? In general I prefer XY charts, although a Line chart provides a nice axis, if you want a tick on the first of each month, say, and the months to be sp...

vb date and ssn textbox formats
Ok, so maybe I am crazy...but I have checked "Visual Basic 6 how t program", and "Visual basic 5 teach yourself in 24 hrs" for and exampl or how to format a text box on a user form to accept and display date and Social Security Numbers in the specified format. Thanks Al -- Message posted from http://www.ExcelForum.com Date TextBox1.Text = Format(Date,"dd mmm yyyy") SSNs TextBox1.Text = Format(mySSN, "000-00-0000") -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mai...

Two calendar dates in one cell..??
I have a Microsoft Publisher calendar document that was created in 2005 that shows the dates Monday - Sunday. When I print it, it will not print out any dates that fall after the fifth week (eg January 2006 it prints up to January 29th but not the 30th or 31st). These are in an "overflow" area. But when I open the calendar part in Word to edit the calendar, it appears normally and that sixth week shows up just fine. I need that sixth week to print OR I need to do the split date feature (I would prefer the split date). How can I set up the numbers in one of those cells so i...

How can I get the trial balloon to work?
I've downloaded the Works program trial balloon over and over, but when I try to use the program it tells me to use a product key and the key I was given (every time) doesn't work. ...