-
ctime library
hi
im trying to read the current time of the computer , but all what i was able to get is the day , month, and year but not the name of the day ( sunday , monday .... ) , im just wondering is there any function in the ctime library that might give me the day name ?
thanks :)
-
-
>im just wondering is there any function in the ctime library that might give me the day name ?
You could use strftime() to format the time.
Code:
#include <ctime>
#include <iostream>
using namespace std;
int main()
{
time_t now = time(NULL);
tm *t = localtime(&now);
char day_of_week[30];
strftime(s, sizeof(day_of_week), "%A", t);
cout << "Today is " << day_of_week << endl;
}