Name

strftime, unix_timestamp, date_iso8601, date_rfc1123 — format datetimes as strings and Unix epoch seconds

Synopsis

varchar strftime( in format varchar,
  in dt datetime);
 
integer unix_timestamp( in dt datetime);
 
varchar date_iso8601( in dt datetime);
 
varchar date_rfc1123( in dt datetime);
 

Description

strftime formats a datetime using a POSIX strftime() format string (e.g. '%Y-%m-%d %H:%M:%S', '%A, %d %B %Y'). The supported conversion specifications follow the host C library; locale-sensitive specifiers use the server's process locale.

unix_timestamp returns the Unix epoch time corresponding to dt — the number of seconds since 1970-01-01 00:00:00 UTC. With no argument it returns the current Unix epoch time (equivalent to unix_timestamp(now())). The result is a signed integer; on 32-bit systems values beyond year 2038 may overflow.

date_iso8601 formats dt as ISO 8601 (e.g. '2026-06-01T15:23:09Z'), preserving the embedded timezone offset.

date_rfc1123 formats dt as the HTTP-Date production from RFC 1123 / RFC 7231 (e.g. 'Mon, 01 Jun 2026 15:23:09 GMT'). The output is always in GMT; any timezone offset on dt is normalised to zero before formatting. Use this for Date, Last-Modified, and Expires HTTP headers.

Examples

Example 24.78. Format the current time

SQL> select strftime ('%Y-%m-%d %H:%M', now());
SQL> select unix_timestamp ();
SQL> select date_iso8601 (now());
SQL> select date_rfc1123 (now());
      


© 1992 - OpenLink Software. All rights reserved.

Making Technology Work for You®