1

How can I store a datetime with SQLAlchemy? Should I even be using DateTime as the column type?

At the moment my date + time is in ISO format from the client (Javascript):

2015-04-13 01:00:00

How would I store this as UTC on the server? Would it be better to have a unix timestamp from the Javascript?

el_pup_le
  • 11,711
  • 26
  • 85
  • 142

1 Answers1

0

Javascript provides Time based on user / client timezone. Thus the time that you get in Javascript will vary as per the user location.

You will have to get the time and client timezone : refer get client timezone and convert it to gmt Then change the time as per UTC and pass it to server and save it in database

Else refer: UTC date and time to get the UTC date / time objects of the client time , form its ISO format and pass it to server n save in DB.

Saving date and time in UTC helps converting time based on user timezone when ever required.

Community
  • 1
  • 1
Vivek Tankaria
  • 1,301
  • 2
  • 15
  • 35