8.5.2. Date/Time Output

8.5.2. Date/Time Output
8.5.2.日期时间输出
The output format of the date/time types can be set to one of the four styles ISO 8601, SQL (Ingres), traditional POSTGRES (Unix date format), or German. The default is the ISO format. (The SQL  standard requires the use of the ISO 8601 format. The name of the “SQL” output format is a historical  accident.) Table 8.14 shows examples of each output style. The output of the date and time types is  generally only the date or time part in accordance with the given examples. However, the POSTGRES  style outputs date-only values in ISO format.
日期/时间类型的输出格式可以设置为ISO 8601,SQL(Ingres),传统POSTGRES(Unix日期格式)或德语四种样式中的一种。默认为ISO格式。(SQL标准要求使用ISO 8601格式。“ SQL”输出格式的名称是历史性的意外。)表8.14列出了每种输出样式的示例。根据给定示例,date和time类型的输出通常仅是日期或时间部分。但是,POSTGRES样式 仅日期的值 以ISO格式输出。
Note
ISO 8601 specifies the use of uppercase letter T to separate the date and time. PostgreSQL  accepts that format on input, but on output it uses a space rather than T , as  shown above. This is for readability and for consistency with RFC 3339 as well as  some other database systems.
ISO 8601指定使用大写字母T分隔日期和时间。PostgreSQL在输入上接受该格式,但是在输出上 ,如上所示 ,它使用的是空格而不是T。这是为了提高可读性并与RFC 3339以及某些其他数据库系统保持一致。
 
In the SQL and POSTGRES styles, day appears before month if DMY field ordering has been specified, otherwise month appears before day. (See Section 8.5.1 for how this setting also affects interpretation  of input values.) Table 8.15 shows examples.
在SQL和POSTGRES风格中, 如果已指定DMY顺序,则日期在月份之前显示,否则月份在日期之前显示。(有关该设置如何影响输入值的解释,请参见第8.5.1节。)表8.15显示了示例。
 
The date/time style can be selected by the user using the SET datestyle command, the DateStyle  parameter in the postgresql.conf configuration file, or the PGDATESTYLE environment variable  on the server or client.
用户可以使用SET datestyle命令,postgresql.conf配置文件中的DateStyle参数或服务器或客户端上的PGDATESTYLE环境变量来选择日期/时间样式。
 
The formatting function to_char (see Section 9.8) is also available as a more flexible way to format  date/time output.
格式化函数to_char(请参见9.8节)也可以作为一种更灵活的方式来格式化日期/时间输出。
发布了341 篇原创文章 · 获赞 54 · 访问量 88万+

猜你喜欢

转载自blog.csdn.net/ghostliming/article/details/104640509
今日推荐