#include
#include
int main() {
// Get the current time
time_t currentTime = time(NULL);
// Convert the current time to the local time
struct tm *localTime = localtime(¤tTime);
// Print the date and time
printf("Current Date and Time: %s", asctime(localTime));
return 0;
}
Rupesh KahanePosted May 31, 2023, 10:11 AM
#include
#include
#include
int main()
{
time_t t;
t = time(NULL);
struct tm tm;
tm = *localtime(&t);
printf("Current Time: %d:%d:%d", tm.tm_hour, tm.tm_min, tm.tm_sec);
// output Current Time: 3:40: 29
printf("Current Date: %d-%d-%d", tm.tm_mday, tm.tm_mon+1, tm.tm_year+1900);
// output Current Date: 31-05-2023
getch();
return 0;
}
Amit MohantyPosted May 31, 2023, 9:58 AM