Go Down

Topic: MKR 1400 get local time, not UTC (Read 673 times) previous topic - next topic

alanoatwork

Jul 21, 2018, 02:35 am Last Edit: Jul 21, 2018, 06:21 am by alanoatwork
The getTime() function appears to return the time in UTC, however when I use the GSM passthrough app and issue the AT+CCLK? command I get the local time.

Is there an easy way to get the local time from within my sketch?  I've given up trying to use Time.h, Timelib.h and Timezone.h as these aren't compatible with MKRGSM.h

alanoatwork

I now see that the getTime function in MKRGSM is adjusting for the local time and returning UTC. It's easy enough to comment out the code but I've made a request to update the library to allow the option of either local time or UTC.

JSSarduino

Could you please post some example code using the getTime function?  Can't find any example code of it anywhere on the web.  I have been trying to use it unsuccessfully for days.  I keep getting "getTime undeclared" compiler errors.  The documentation on the Arduino website I have found to be so short its useless.  Short version of my code:

#include <MKRGSM.h>

// initialize the library instance
GSMClient client;
GPRS gprs;
GSM gsmAccess;

void loop() {
  long int epoch = getTime();
}

Keep getting this error
"'getTime' was not declared in this scope"

Any help would be great!

MVE

@JSSarduino getTime(); function is part of GSM class so you have to call it like this:

gsmAccess.getTime();

Go Up