Direct AT Commands to shield (for getting time)

Got it to work to read out the IMEI number.

// Initialize the GSM library instance
GSMClient client;
GPRS gprs;
GSM gsmAccess(true); // True for debugging

call gsmAccess.begin() so the modem is started... and then this function works:

String imei;
void readIMEI(){
    GSM3ShieldV1DirectModemProvider modemAccess;
    modemAccess.begin();
    int tries = 10;
    while (imei.length() < 15 && tries>0) {
      imei = modemAccess.writeModemCommand("AT+GSN", 2000);
      
      Serial.print(F("IMEI: "));
      Serial.println(imei);
      tries--;
    }
    int i;
    String imei2="";
    for (i=0;i<imei.length();i++) {
      char a = imei[i];
      Serial.println(a);
      if (a >= '0' && a<='9') imei2 = imei2 + a; //Remove any characters except the numbers.
      Serial.println(imei2);
    }
    imei = imei2;
}