Question: I'm trying to get from a time formatted Cell (hh:mm:ss) the hour value, the values can be bigger 24:00:00 for example 20000:00:00 should give 20000:

Table: 

![two Google Spread Sheet](https://i.stack.imgur.com/cgPfp.png)

if your read the Value of E1: 

```
var total = sheet.getRange("E1").getValue();
Logger.log(total);

```

The result is: 

> 
> Sat Apr 12 07:09:21 GMT+00:09 1902
> 
> 
> 

Now I've tried to convert it to a Date object and get the Unix time stamp of it:

```
  var date = new Date(total);
  var milsec = date.getTime();
  Logger.log(Utilities.formatString("%11.6f",milsec));
  var hours = milsec / 1000 / 60 / 60; 
  Logger.log(hours)

```

> 
> 1374127872020.000000
> 
> 
> 381702.1866722222
> 
> 
> 

The question is how to get the correct value of 20000 ?

Answer: 
There are two new functions `getDisplayValue()` and `getDisplayValues()` that returns the datetime or anything exactly the way it looks to you on a Spreadsheet. Check out the documentation [here](https://developers.google.com/apps-script/reference/spreadsheet/range#getdisplayvalue)
For simple spreadsheets you may be able to change your spreadsheet timezone to GMT without daylight saving and use this short conversion function:

```
function durationToSeconds(value) {
  var timezoneName = SpreadsheetApp.getActive().getSpreadsheetTimeZone();
  if (timezoneName != "Etc/GMT") {
    throw new Error("Timezone must be GMT to handle time durations, found " + timezoneName);
  }
  return (Number(value) + 2209161600000) / 1000;
}

```

Eric Koleda's answer is in many ways more general. I wrote this while trying to understand how it handles the corner cases with the spreadsheet timezone, browser timezone and the timezone changes in 1900 in Alaska and Stockholm.