CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2004
    Posts
    20

    Obtain System Time

    I'm using WinXP. Can anyone please tell me how to obtain system time and then display it in an edit box?

    Thanks for helping.

  2. #2
    Join Date
    Sep 1999
    Location
    France
    Posts
    393

    Re: Obtain System Time

    Here is how I done it

    Code:
                    CString string;
    	struct tm *local=localtime(&t);;
    	string.Format( _T("%02d/%02d/%04d   %02d:%02d:%02d"),	
    						local->tm_mday,
    						local->tm_mon+1,
    						local->tm_year+1900,
    						local->tm_hour,
    						local->tm_min,
    						local->tm_sec );
    Regards

  3. #3
    Join Date
    Sep 1999
    Location
    France
    Posts
    393

    Re: Obtain System Time

    I miss something

    Code:
    	time_t t = time(NULL);
             CString string;
    	struct tm *local=localtime(&t);;
    	string.Format( _T("%02d/%02d/%04d   %02d:%02d:%02d"),	
    						local->tm_mday,
    						local->tm_mon+1,
    						local->tm_year+1900,
    						local->tm_hour,
    						local->tm_min,
    						local->tm_sec );

  4. #4
    Join Date
    Nov 2001
    Posts
    323

    Re: Obtain System Time

    use COleDateTime::GetCurrentTime()
    and you can Format it to display however you wish, check the msdn for the options
    create a control variable for the text box and dump the time as a string into it using SetWindowText
    Best Regards,

    --Zim
    If you find this post useful, please rate it.
    _________________________________
    "Have you the brain worms?!?!?"

  5. #5
    Join Date
    Feb 2002
    Posts
    3,788

    Re: Obtain System Time

    Quote Originally Posted by fitcher
    I'm using WinXP. Can anyone please tell me how to obtain system time and then display it in an edit box?

    Thanks for helping.
    void GetSystemTime(
    LPSYSTEMTIME lpSystemTime
    );

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured