我使用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