C/C++ Systemdatum!?

Halli Hallo, da bin ich wieder mal ^^

Ich hab es schon in meiner letzten Frage etwas angeschnitten:

Leider finde ich weder hier noch im MSDN.Net etwas
wie ich gscheit das Systemdatum bekomme :-/

kann mir da jemand weiterhelfen, aber bitte kein CTime, weil das
geht irgendwie überhaupt nicht ^^

Danke schon jetz an alle user ^^
KenshinX
 
Keine Ahnung ob es funktioniert, ist nur geklaut. :D

Code:
#include <windows.h> //Für 'GetSystemTime'  
#include <iostream> //Für 'cout'  
using namespace std;    

SYSTEMTIME tm;
GetSystemTime(&tm);
cout << tm.wHour << ":" << tm.wMinute << ":" << tm.wSecond << "." << tm.wMilliseconds << endl;

Das wäre dann aber erstmal die Zeit, aber für das Datum gibt es sicherlich auch einige Variablen, die in der C++/Bibliothek stehen.
 
hey, cool, danke ;)
durch rumprobieren ist dein Codestück sehr Hilfreich.
Fals es ein anderer einmal benötigen sollte:


SYSTEMTIME tm; // tm ist eine classenvariable von SYSTEMTIME
GetSystemTime(&tm); // Systemzeit und alle anderen daten werden übergeben

mit

tm.wHour
wSecond
wMilliSecond
wMinute
wDay
wMonth


usw kann man das dann schön abrufen
die daten können übrigens mit den Platzhalter für Integer ausgegeben werden

Vielen Dank nochmal an dich ;)
 
und wie geht das, wenn ich die systemvariablen benutze ( %time% und %date% )
?
wie kann ich die für mein eprogramme verämdern
 
Code:
#include <iostream>
#include <windows.h>
#include <time.h>

using namespace std;

void main()
{ 
SYSTEMTIME tm;
GetLocalTime(&tm);

cout<<"\n\tDie Aktuelle Zeit ist  \xAF "<<tm.wHour<<":"<<tm.wMinute<<" Uhr"<<endl;
cout<<"\n\tDas Aktuelle Datum ist \xAF "<<tm.wDay<<"."<<tm.wMonth<<"."<<tm.wYear<<endl<<endl<<endl;	
}

Und hier die Möglichen Variablen der Struktur SYSTEMTIME:

wYear
Specifies the current year.
wMonth
Specifies the current month; January = 1, February = 2, and so on.
wDayOfWeek
Specifies the current day of the week; Sunday = 0, Monday = 1, and so on.
wDay
Specifies the current day of the month.
wHour
Specifies the current hour.
wMinute
Specifies the current minute.
wSecond
Specifies the current second.
wMilliseconds
Specifies the current millisecond.
 
Zurück
Oben