AT commandes to get date/time

Hi everyone Im using a GSM shield with M10, and i need to get to know the date and time, So i was thinking about using AT commandes ...
can anyone help me with that please ?
any kind of help is appreciated !

AT+CCLK? reads the date/time

AT+CCLK="yy/mm/dd,hh:mm:ss+zz" sets the time (zz is the time difference from UTC, if you use it rather than local time. However, there must be a value even if it is only 00)

OOOk thank you !!
now what if i want to keep that date ? I mean store it into a variable so i can use it ... is it possible ? :confused: :confused:

Of course you can store it in a variable. What have you tried?

#include <GSM.h>

// initialize the library instance
GSM gsmAccess;
GPRS gprsAccess;

GSM3ShieldV1DirectModemProvider modemAccess;

// PIN Number
#define PINNUMBER "****"

// APN info
char apn[] = {""};
char login[] = {""};
char password[] = {""};

String inputString = "";         // a string to hold incoming data
boolean stringComplete = false;  // whether the string is complete


void setup(){
  Serial.begin(9600);
  connectGSM();
}
void loop(){
  // print the string when a newline arrives:
  if (stringComplete) {
    Serial.print("Sending command: "+inputString);
    Serial.println(send_AT_Command(inputString,1000)); 
    // clear the string:
    inputString = "";
    stringComplete = false;
  }
   
}
String send_AT_Command(String AT_COMMAND, int tDelay){
  Serial.print("COMMAND: "+AT_COMMAND);
  Serial.println(modemAccess.writeModemCommand(AT_COMMAND,tDelay));
  Serial.println("-----------------------------------------------");
  
  return modemAccess.writeModemCommand(AT_COMMAND,tDelay);
}
void serialEvent() {
  while (Serial.available()) {
    // get the new byte:
    char inChar = (char)Serial.read(); 
    // add it to the inputString:
    inputString += inChar;
    // if the incoming character is a newline, set a flag
    // so the main loop can do something about it:
    if (inChar == '\n') {
      stringComplete = true;
    } 
  }
}
void connectGSM(){
  boolean notConnected=true;
  Serial.println("Connecting...");
  while(notConnected){
    if(gsmAccess.begin(PINNUMBER) == GSM_READY)
      notConnected = false;
    else { Serial.print("not connected, trying again");
      delay(1000); }
  }
  Serial.println("Connected to GSM, now GPRS...");

  // 1000ms bug
  delay(1000);
  
  while(gprsAccess.attachGPRS(apn, login, password)!=GPRS_READY){
    delay(1000);
  }
  Serial.println("Fully connected.");
}

I can't see any reference to AT+CCLK in that code.

Sorry, I used this one to get the date and time :

#include <GSM.h>
GSM gsmAccess(true);

char answer[100];

void setup()
{
 Serial.begin(9600);
 
 boolean notConnected = true;
 
 Serial.println("Connecting to the GSM network");
 
 while(notConnected){
   if(gsmAccess.begin("xxxx") == GSM_READY)
     notConnected = false;
   else {
     Serial.println("Not connected, trying again");
     delay(1000);
   }
 }
 
 Serial.println("Connected. Sending AT Command.");
 theGSM3ShieldV1ModemCore.println("AT+CCLK?"); 
}

void loop()
{

}