The number of seconds between 2 Dates
value.getTime() returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by a Date object.

You don't need a ConvertToTimestamp method, just call value.getTime() / 1000 to get the seconds.