Remove unwanted characters from char type I'm working on an ESP8266 module that needs to fetch date data from worldtimeapi, everything works fine but the problem is How do I strip of the time field off the datetime JSON response without loop.
Note: Arduino JSON library was used in deserializing the response data and it seems the library only supports char data type.
void loop ()
{
  // Initialize the request object
  HTTPClient request;
  
// Make a http request
  request.begin(dateTime);
  delay(2000);

  // Check the request status code.
int  responseCode = request.GET(); //Get the api host response code.
  Serial.print(&quot;Response code is: &quot;);
  Serial.println(responseCode);
  if (responseCode == 200); // If the server returned OK
  {
      String responseData = request.getString();
      Serial.println(&quot;Response from the server is:&quot;);
      Serial.println(responseData);
        // Deserialize the JSON response data
       StaticJsonDocument&lt;715&gt; result; // Declare data storage to stack
      
      //Check for error during data deserialization
      DeserializationError error = deserializeJson(result, responseData);
      
      if (error) 
      {
        Serial.print(F(&quot;Response deserialization failed with reason: &quot;));
        Serial.println(error.f_str());
        return;
      }

      else
      {
        char abbreviation = result[&quot;abbreviation&quot;];  // Returns the current time zone abbreviation
        char timezone = result[&quot;timezone&quot;]; // Returns the current time zone 
        char datetime = result[&quot;datetime&quot;]; // &quot;2021-03-12T17:04:0
        char date = datetime.remove(9,22); // This line throws error : request for member 'remove' in 'datetime', which is of non-class type 'char'

          
        
        Serial.print(&quot;Current time is &quot;);
        Serial.print(datetime);
        Serial.print(&quot; &quot;);
        Serial.print(abbreviation);
        Serial.print(&quot; &quot;); 
        Serial.println(timezone);
        delay(2000);
      }
      
  }


}
You can use strtok to split the string on the T character:
char *datepart = strtok(datetime, &quot;T&quot;);
char *timepart = strtok(NULL, &quot;T&quot;);

Serial.print(&quot;The current date is: &quot;);
Serial.println(datepart);
Serial.print(&quot;The current time is: &quot;);
Serial.println(timepart);

An alternative is to just find the T and turn it into the NULL terminating character:
char *T = strchr(datetime, 'T');
*T = 0;


If you need to copy the string data into a temporary string first you can do:
char temp[strlen(datetime)+1];
strcpy(temp, datetime);

Then operate on temp instead of datetime.