Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Google Apps script how do I get millisecond value without exponent?

I am trying to send a millisecond timestamp to a web service using UrlFetch in a google app script. My web service expects the time in the format 1433563200021, but google app script keeps converting it to a string with an exponent: 1.433563200021E12, even if I call Number(startDate.getTime()). How do I get google app script to store just the numeric value in a variable?

like image 878
Alex Egli Avatar asked May 18 '26 16:05

Alex Egli


1 Answers

I found out that you can call the toFixed(0) method to force it to remove the exponential format. E.g.

var start = new Date();
var startTime = Number(start.getTime()).toFixed(0);
like image 161
Alex Egli Avatar answered May 22 '26 23:05

Alex Egli