我使用Matlab datainsert
函數將格式爲'yyyy-mm-dd hh:mm:ss'的字符串插入到PostgreSQL數據庫中的帶時區字段的時間戳中,沒有任何問題。但是,我似乎無法確定如何在字符串本身中包含時區,所以Postgres假定它具有我的區域設置的時區。應如何格式化時區在Matlab中,將字符串插入帶時區的postgresql字段時間戳時?
例如
create table tmp_test (
id serial primary key,
time timestamp with time zone NOT NULL
);
然後,這個工程:
datainsert(conn, 'tmp_test', {'time'}, {'2016-09-15 03:45:49.326'})
但這並不:(?)
>> datainsert(conn, 'tmp_test', {'time'}, {'2016-09-15 03:45:49.326 +00:00'})
Error using database/datainsert (line 301)
Unable to insert element in row 1 column 1, 2016-09-15 03:45:49.326 +00:00. Timestamp format must be yyyy-mm-dd
hh:mm:ss[.fffffffff]
可能重複的[我如何插入timezone與Postgresql與準備好的語句時間戳?](http://stackoverflow.com/questions/13676168/how-can-i-insert-timestamp-with-timezone- in-postgresql-with-prepared-statement) – Alex