Search code examples
javasqlgoogle-app-enginetimezonegoogle-cloud-sql

Timestamp issue after deploying the app on App Engine


I am developing an application that needs to record the timestamp in an Sql column(default set to CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP) whenever any database operation takes place.

After deploying the application on App Engine, I do get timestamp in the Sql column but I have no idea where it's picking the timestamp from(I guess it's the timestamp from the server the app is running on or Google Cloud SQl is running on).

If I need timezone information on the same, how can I get it ? Or is there a better way to record such information like generating the timestamp using java code java.util.Date date= new java.util.Date(); and storing the same in sql column and which timezone/time it will pick then ?


Solution

  • Since the application runs on GAE after deploying and the GAE server is set to GMT, using java to generate the timestamp or even setting the table on the cloud sql to generate timestamp automatically, will be as per the server's time and therefore is not useful for my application.

    So, as a work around, in order to record the timestamp of a user accessing the application, I am generating timestamp through javascript using new Date(); and storing the same as a string in the sql table on the cloud.

    Well, this is half of my requirement as I currently have no way to display this stored timestamp to a user according to his time zone, which could be different from what's stored in the table. Thanks