Arduino Forum

Products => MKR Boards => MKRGSM1400 => Topic started by: alanoatwork on Jul 21, 2018, 02:35 am

Title: MKR 1400 get local time, not UTC
Post by: alanoatwork on Jul 21, 2018, 02:35 am
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
Title: Re: MKR 1400 get local time, not UTC
Post by: alanoatwork on Jul 21, 2018, 11:55 pm
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.
Title: Re: MKR 1400 get local time, not UTC
Post by: JSSarduino on Aug 17, 2018, 06:33 am
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!
Title: Re: MKR 1400 get local time, not UTC
Post by: MVE on Nov 22, 2018, 04:45 pm
@JSSarduino getTime(); function is part of GSM class so you have to call it like this:

gsmAccess.getTime();