time_t rawtime;
	struct tm * timeinfo;
	char sec [80];
	char min [80];
	char hour [80];
	char year[80];
	char month[80];
	char day[80];
	time ( &rawtime );
	timeinfo = localtime ( &rawtime );
	string timetest;
	timetest= strftime (sec,80,"%S",timeinfo);
	timetest= strftime (min,80,"%M",timeinfo);
	timetest= strftime (hour,80,"%H",timeinfo);
	timetest= strftime (year,80,"%Y",timeinfo);
	timetest= strftime (month,80,"%m",timeinfo);
	timetest= strftime (day,80,"%d",timeinfo);

is there away to put it into a func or class or is there a better way to get the date and time?

Recommended Answers

All 3 Replies

Yes. The same way you put anything into a function.

Yes. The same way you put anything into a function.

but i dont know how to get the seconds,year etc out side the function
i tried to convert the char to int then return it back but i still cant figure out how for e.g to set the value of sec to a new variable called Seconds ....

anyclue??

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.