Hi,
I am able to create a clock in a console c++ app...like this one show UTC hours:

#include "stdafx.h"
#include <iostream>
#include <windows.h>
#include <stdio.h>

void main()
{
    SYSTEMTIME st, lt;
    
    GetSystemTime(&st);
    GetLocalTime(&lt);
    
	std::cout << st.wHour << std::endl;
	std::cin.get();
}

But I am not able to create this with the .NET Framework 3.5, I mean Windows Forms.
I want to assign HOURS : MINUTES : SECONDS to a label.
Can you help me out?


Regards

Recommended Answers

All 3 Replies

Look into a DateTime object: http://msdn.microsoft.com/en-us/library/system.datetime_members(v=VS.90).aspx

Create an instance of a DateTime object and set it equal to DateTime::Now, then just use the hours, minutes, seconds members to get what you need.

If you want it to update every second, use a Timer object.

Look into a DateTime object: http://msdn.microsoft.com/en-us/library/system.datetime_members(v=VS.90).aspx

Create an instance of a DateTime object and set it equal to DateTime::Now, then just use the hours, minutes, seconds members to get what you need.

If you want it to update every second, use a Timer object.

Sorry, but that's kinda too complicated to me, isn't there an easier way?


Regards

That's actually probably the least complicated way. What problems are you having in implementing it?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.