Reputation: 522
I have written a stand-alone script that stores dates (Date type field) in a mySQL database using Google Apps Script JDBC object. The timezone of the dates is UTC.
I do a query that selects all the dates, as an example:
SELECT Date1
FROM Table1
When I retrieve the data using GetObject(1), it returns a Date object having PDT timezone set. To be more precise, when I prompt theDate.toString(), it gives me: Mon Jul 30 2012 23:51:25 GMT+0200 (CEST) I notice that the original date (2012-07-30 14:51:25) from db has been considered as PDT and converted to GMT+2.
The Script timezone is not related and is set to GMT+1...
How can I tell to JDBC that the dates from the database are UTC?
Thanks
Upvotes: 0
Views: 910
Reputation: 12673
Some debugging done in Issue 1642 indicates that this is due to how JDBC works with MySQL, and the connection flags required to fix it currently can't be set in Apps Script.
To be clear through, the timezone shown when converting a JavaScript Date to a string will always be the timezone of the server, in this case Pacific Time. Use Utilities.formatDate to display a Date in a specific timezone.
Upvotes: 2