title: How to get google sheet's cell values as is using google script
body: <p>I'm about to use google sheet as my database for my android app small project. I'm using Google Script to handle the request from my app.</p>
  
  <p>In my google sheet, I store;</p>
  
  <ul>
  <li><p>A2:A = date as dd/mm/yyyy e.g 21/12/2019 but
  the display format is dd-MMM e.g 21-Dec</p></li>
  <li><p>C2:D = time as hh:mm:ss e.g 21:00:00 but
  the display format is hh:mm e.g 21:00</p></li>
  </ul>
  
  <p>Yes, I need a different format for the display and input.</p>
  
  <p>My google sheet:</p>
  
  <p><a href="https://i.stack.imgur.com/8tP9w.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8tP9w.png" alt="enter image description here"></a></p>
  
  <p>When I use google script to get a value of the cell, it seems that it is reformatted</p>
  
  <p>the date looks like this: <code>Sat Jan 01 2019 00:00:00 GMT+0700 (ICT)</code>
  the time the other hand, change in value a bit. 20:00:00 to 19:52:48</p>
  
  <p>Is there any function to get cell real values as text without being reformatted?</p>
  
  <p>The only thing that I can think of is instead of using getValues(), I can use getDisplayValues(). The values will not be reformatted, but it is not a solution for me, as it will take the display format.</p>
  
  <p>Snippet of my code:</p>
  
  <pre><code>function updateData(e, sheet) {
    var tgl = e.parameter.tgl;
    var dtg = e.parameter.dtg;
    var plg = e.parameter.plg;
    var lbr = e.parameter.lbr;
  
    var rangeHead = sheet.getRange("A2:A");
    var valuesHead = rangeHead.getValues();
  
    var rangeFirst = sheet.getRange("C2:D")
    var valuesFirst = rangeFirst.getValues();
  
    var rangeSecond = sheet.getRange("G2:G")
    var valuesSecond = rangeSecond.getValues();
  
    for (var i = 0; i &lt; valuesHead.length; i++) {
      if (valuesHead[i][0] === tgl) {
        if(dtg!="null") { valuesFirst[i][0] = dtg; }
        if(plg!="null") { valuesFirst[i][1] = plg; }
        if(lbr!="null") { valuesSecond[i][0] = lbr; }
        break;
      }
    }
    rangeFirst.setValues(valuesFirst);
    rangeSecond.setValues(valuesSecond);
  }
  </code></pre>
  
  <p>The code won't work as I will comparing <code>21/12/2019</code> with <code>Sat Jan 01 2019 00:00:00 GMT+0700 (GMT)</code>. </p>
  
  <p>[UPDATE 1]:
  Thank you P-Burke for the enlightenment. Now, I have an idea to solve the date problem. I know that the script pulls the date as date object, but I am unaware that it also saves as a date object. (hehe my bad) I don't realize it as there is no autocomplete when I call values[0][0]. of course, as it recognizes the object type at the run time.</p>
  
  <p>So, my workaround will be; I will call getDate, getMonth+1, and getYear. After that, I will compare with my parameter freely.</p>
  
  <p>Though, the time cell still a bit confusing for me. the time offset is 18 minutes 12 seconds. I don't think it's because of timezone different and my computer clock. the timezone different is too big and I 've made sure that the script, spreadsheet, and local timezone all the same. My computer clock is also only a minute less behind.</p>
  
  <p>[UPDATE 2]:
  Alright, enough with the confusion. It seemed that the script converts the time to Date object respect to my local timezone. I got this answer from another thread. So, actually, my local timezone changes many times and some of them have offset smaller than hours unit (one of the timezones used in my area is UTC +7:07:12h). The only source documenting those changes I could find is from <a href="https://www.timeanddate.com/time/zone/indonesia/jakarta" rel="nofollow noreferrer">https://www.timeanddate.com/time/zone/indonesia/jakarta</a>. Finally, I gave up. For my goodness sake, I will just use getDisplayValue and ignore the seconds. Unless you guys have any other workaround, I will be so grateful.</p>
  
  <p>Thank you once again to the community.</p>