Hi everyone
I just started to explore the TinyGPS++ library, which I am finding very useful. However, I am trying to convert the YYYY number (e.g.: "2014") into YY ("14"). I've tried snprintf but haven't had any luck. Does anyone have any examples that I could use to achieve this?
Thanks!
#include <TinyGPS++.h>
static const uint32_t GPSBaud = 9600;
TinyGPSPlus gps;
void setup()
{
Serial.begin(9600);
Serial1.begin(GPSBaud);
Serial.println();
}
void loop()
{
// Dispatch incoming characters
while (Serial1.available() > 0)
gps.encode(Serial1.read());
if (gps.date.isUpdated())
{
//////////// Print the date & time...
char datetime_string[18]; //make this big enough to hold the resulting string
snprintf(datetime_string, sizeof(datetime_string), "%02d/%02d/%2d %02d:%02d:%02d",
gps.date.month(), gps.date.day(), gps.date.year(), gps.time.hour(), gps.time.minute(), gps.time.second());
//buffer now contains a string like 02/22/13 05:03:06
Serial.print(datetime_string);
Serial.println(" ");
}
}