-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDigital_clock.cpp
More file actions
32 lines (21 loc) · 924 Bytes
/
Copy pathDigital_clock.cpp
File metadata and controls
32 lines (21 loc) · 924 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <windows.h>
#include <iostream>
#include <chrono>
// #include <thread>
#include <ctime>
#include <iomanip>
using namespace std;
int main(){
while(true){
auto currentTime=chrono::system_clock::now(); // Taking current time from the system using chrono library
time_t now=chrono::system_clock::to_time_t(currentTime); // Converting the time to time_t type
tm* Time_in_localTime = localtime(&now); // Converting the time to local time
system("cls"); // Clearing the screen
// printing of time and date
cout<<put_time(Time_in_localTime,"%H:%M:%S")<<endl;
cout<<put_time(Time_in_localTime,"%d:%m:%Y")<<endl;
cout<<put_time(Time_in_localTime,"%A")<<endl; // For day of the week
// this_thread::sleep_for(chrono::seconds(1));
Sleep(1000); // Stops the operations for 1 second
}
}