Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

how to read system time in c++

Status
Not open for further replies.

ehsanelahimirza

Full Member level 6
Joined
Feb 24, 2006
Messages
334
Helped
28
Reputation
56
Reaction score
7
Trophy points
1,298
Activity points
3,570
how to read system time in c

hi all

plz tell me how to read system time as

hour
minutes
seconds
AM/PM

in c++

what variables will store these values
plz if give algo + any working example( compiler visual c)
 

sztime c++

hi ehsanelahimirza!

Use CTime an MFC class.

CTime ct = CTime::GetCurrentTime();

int minute = ct.GetMinute();
int hour = ct.GetHour();
int seconds=ct.GetSecond();


An Microsoft examples:

void CMainFrame::OnUpdateTime(CCmdUI *pCmdUI)
{
CTime t = CTime::GetCurrentTime();
char szTime[6];
int nHour = t.GetHour();
int nMinute = t.GetMinute();

// Base Hours on 12 instead of 24
if (nHour > 12)
nHour = nHour - 12;

wsprintf(szTime, "%i:%02i", nHour, nMinute);

// Now set the text of the pane.
m_wndStatusBar.SetPaneText(
m_wndStatusBar.CommandToIndex(ID_INDICATOR_TIME),
LPCSTR(szTime));
pCmdUI->Enable();
}
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top