time

Rails Activerecord/Postgres time format

有些话、适合烂在心里 提交于 2020-08-27 05:56:39
问题 I am working on a Rails project using a Postgres database. For one of my models, I have a time column, called (cleverly) time. When I created the model, I set the data type for this column as 'time', with the (perhaps incorrect) understanding that this data type was for storing time only, no date. t.time :time However, when I submit data to the model, the time is correct but prefixed by an incorrect date: time: "2000-01-01 16:57:19" I just want the column to store the time (like '16:57:19').

UTC vs ISO format for time

六月ゝ 毕业季﹏ 提交于 2020-08-24 10:44:35
问题 I'm trying to understand the difference between UTC and ISO formats and when to use what when transferring messages between servers. So When I try the following this is what I get new Date().toISOString() "2019-11-14T00:55:31.820Z" new Date().toUTCString() "Thu, 14 Nov 2019 00:55:16 GMT" I understand the ISO format and its a standard used to represent time, but what is the purpose of UTC and where would I use them? 回答1: tl;dr Always use ISO 8601 format: 2019-11-14T00:55:31.820Z Avoid the