Google Script Date Showing Wrong "hours"
I feel as if I have poured over nearly all of the documentation regarding dates in JS and GAS. Especially concerning DST issues. Since I have not had a problem like this until the
Solution 1:
what I usually use without any issue is simply that :
varFUS1=newDate(dateObject).toString().substr(25,6)+":00";// get the timeZone part of the string coming from the date you are working on (an event)
dateString = Utilities.formatDate(dateObject, FUS1, "MM/dd/yyyy HH:mm:ss");// use it in formatDate and it will have the right value for every season...
note that you were using date
2 times in your example code :once as a string result and once as a date object in the same line...
Edit following your comment :
assuming for example that the datestamp is in A2, the following code should return the right time.
var date= SpreadsheetApp.getActiveSheet().getRange('A2').getValue();
var FUS1=newDate(date).toString().substr(25,6)+":00";
dateString = Utilities.formatDate(date, FUS1, "MM/dd/yyyy HH:mm:ss");
Post a Comment for "Google Script Date Showing Wrong "hours""