LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

how to display system date and time in Labwindows/CVI?

I want to display current system date and time in the main panel in Labwindows/CVI?How can i realize it? Could u give me a Demo CVI programm ? Thanks a lot! I am a new user.
0 Kudos
Message 1 of 3
(8,825 Views)
The easiest way to obtain the system date and time in a string is to use the following statements:

static char *z = NULL;
static struct tm *tm;
static time_t tt;

time (&tt);
tm = localtime (&tt);
z = asctime (tm);
DebugPrintf ("System time: %s\n", z);

You can paste those lines in the Interactive execution window and run them by pressing Shift-F5: the debug window will open showing this message:

System time: Wed Sep 24 10:27:03 2003


In some case I noticed in the past that this method was not up to the time zone and daylight savings time settings, so to obtain current (local) date and time, I begun to use the following SDK function:

#include
#include
static char a[50];
static SYSTEMTIME dh;

GetLocalTime(
&dh);
sprintf (a, "%d/%d/%04d %d:%02d", dh.wMonth, dh.wDay, dh.wYear, dh.wHour, dh.wMinute);
#include
DebugPrintf ("Local date and time are: %s\n", a);

Again, paste in the Interactive execution window and run. In the Debug window you will see the following message:

Local date and time are: 9/24/2003 10:33


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 3
(8,825 Views)
Hello,
You may also want to check
"GetSystemDate" and "GetSystemTime" functions in the Utility library
Regards,
Marco

"gpibssx" a écrit dans le message de
news:50650000000800000048A30000-1042324653000@exchange.ni.com...
> I want to display current system date and time in the main panel in
> Labwindows/CVI?How can i realize it? Could u give me a Demo CVI
> programm ? Thanks a lot! I am a new user.
Message 3 of 3
(8,825 Views)