I need to find the current date and time for use it in a function, not display it. Everything I found so far just displays the current date and time , and will not let me use it to do my calculation. If I can find out time and date separately would also work.
get system's current date and time
Page 1 of 15 Replies - 697 Views - Last Post: 29 August 2012 - 02:05 AM
Replies To: get system's current date and time
#2
Re: get system's current date and time
Posted 29 August 2012 - 01:27 AM
Your google-fu needs some help. Here's what I found with the keywords: "C++ date time":
http://www.cplusplus...clibrary/ctime/
Which unfortunately actually C. The real C++ functions are here:
http://en.cppreferen...om/w/cpp/chrono
http://www.cplusplus...clibrary/ctime/
Which unfortunately actually C. The real C++ functions are here:
http://en.cppreferen...om/w/cpp/chrono
#4
Re: get system's current date and time
Posted 29 August 2012 - 01:29 AM
Hi,
there is also _strdate and _strtime in ctime
there is also _strdate and _strtime in ctime
#include <iostream>
#include <ctime>
int main ()
{
char date [10];
_strdate(date);
std::cout<<"Current Date is: "<<date<< std::endl;
char time [10];
_strtime(time);
std::cout<<"Current Time is: "<<time<< std::endl;
return 0;
}
#5
Re: get system's current date and time
Posted 29 August 2012 - 01:47 AM
[quote name='Skydiver' date='29 August 2012 - 01:27 AM' timestamp='1346228836' post='1692555']
Your google-fu needs some help. Here's what I found with the keywords: "C++ date time":
http://www.cplusplus...clibrary/ctime/
Which unfortunately actually C. The real C++ functions are here:
http://en.cppreferen...om/w/cpp/chrono
[I said I need second , minute and hour ! and don't want to cout it !!!! ]
Your google-fu needs some help. Here's what I found with the keywords: "C++ date time":
http://www.cplusplus...clibrary/ctime/
Which unfortunately actually C. The real C++ functions are here:
http://en.cppreferen...om/w/cpp/chrono
[I said I need second , minute and hour ! and don't want to cout it !!!! ]
#6
Re: get system's current date and time
Posted 29 August 2012 - 02:05 AM
I don't see anyplace in your post #1 that you needed second, minute, and hour.
And there is no requirement for you to output values using cout. The sample code was just there to demonstrate retrieving the time and printing it out.
And there is no requirement for you to output values using cout. The sample code was just there to demonstrate retrieving the time and printing it out.
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote




|