I've got a couple projects going that keep a current time stamp on an lcd. One I'm brute forcing the time stamp via:
lcd.setCursor(0, 0);
if (now.month() < 10)
lcd.print("0");
lcd.print(now.month(), DEC);
lcd.print('/');
if (now.day() < 10)
lcd.print("0");
lcd.print(now.day(), DEC);
lcd.print('/');
lcd.print(now.year(), DEC);
lcd.print(" ");
if (now.hour() < 10)
lcd.print("0");
lcd.print(now.hour(), DEC);
lcd.print(':');
if (now.minute() < 10)
lcd.print("0");
lcd.print(now.minute(), DEC);
lcd.print(':');
if (now.second() < 10)
lcd.print("0");
lcd.print(now.second(), DEC);
The second its streamlined to:
lcd.setCursor(0, 0);
lcd.print(__DATE__);
I like the fact that the streamlined/second code yields the month's abbreviation but when there are less than 10 days it leaves a blank for the initial character. I know how to eliminate that as done in first code. However, is there a function call that also does this without needing all the code as the first I've included? Do I need to use strings if I want to go this route or do I just need to brute the month into the first code? Imagined there is an easier way.