Hello. This is my first post so please correct me if my formatting is awful.
I am trying to have a simple date and time print onto the monitor. I am able to print the values using their corresponding functions from processing, however I would like them to update an match the actual time on each iteration of draw(). Right now they will match the time I initialized the program and remain static.
int M = month(); //month
int D = day(); //day
int Y = year(); //year
int Hr = hour(); //hour
int Min = minute(); //minute
int Sec = second(); //second
PFont dateAndTime;
void setup() {
size(400, 400);
background(0);
dateAndTime = createFont("Monospaced", 20);
}
void draw() {
background(0);
displayDate();
displayTime();
textAlign(CENTER);
}
//-----------------------------------------------------------
void displayDate() {
String Ms = str(M);
String Ds = str(D);
String Ys = str(Y);
String MDY = Ms + "/" + Ds+ "/" + Ys;
textFont(dateAndTime);
text(MDY, 200, 180);
}
//------------------------------------------------------------
void displayTime() {
String Hrs = str(Hr);
String Mins = str(Min);
if (Mins.length() < 2) {
Mins = "0" + Mins;
}
String Secs = str(Sec);
if (Secs.length() < 2) {
Secs = "0" + Secs;
}
String HMS = Hrs + ":" + Mins + ":" + Secs;
textFont(dateAndTime);
text(HMS, 200, 200);
}
Any ideas on how to do this?