title: React How to pass field date from datepicker as Api url parameter
body: <p>I am fetching data from an API that has a date as a parameter<br />
  this date comes from the material picker of react the format for date should be yyyy-MM-dd, but when I select a date with my datepicker it passes date as</p>
  <blockquote>
  <p>Tue Oct 12 2021 00:00:00 GMT+0000 (Greenwich Mean Time)
  I want the date sent by datpiecker to be as my required format: <code>yyyy-MM-dd</code>
  this is a prt of my code :</p>
  <pre><code>import React, { useState, useCallback, useEffect } from &quot;react&quot;;
  import DateFnsUtils from &quot;@date-io/date-fns&quot;;
  import {DatePicker, KeyboardDatePicker,MuiPickersUtilsProvider,} from &quot;@material-ui/pickers&quot;;
  
  function ExchangeRate() {
    
  
      const [date, setDate] = useState(moment().format(&quot;YYYY-MM-DD&quot;));
     
  
      useEffect(() =&gt; {
     
    
      function getExchangeRates(base, currencyCode) {
         
          const url = `https://data.fixer.io/api/${date}?&amp;base=USD`;
  
          
          return fetch(url)
              .then((res) =&gt; res.json())
              .then(handleAPIErrors)
              .then((res) =&gt; res.rates);
  return (
            
            
                      &lt;/CSelect&gt;
                 
                
  
  
                    
            &lt;MuiPickersUtilsProvider utils={DateFnsUtils}&gt;
      
              &lt;KeyboardDatePicker
              autoOk
                label=&quot;Material Date Picker&quot;
                format=&quot;yyyy-MM-dd&quot;
                animateYearScrolling
                value={date}
                onChange={date =&gt; setDate(date)}
              /&gt;
              
            &lt;/MuiPickersUtilsProvider&gt;
  </code></pre>
  </blockquote>