diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index 34fea16eee..ae22ee5f7f 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -6684,8 +6684,10 @@ SELECT EXTRACT(DOY FROM TIMESTAMP '2001-02-16 20:38:40');
epoch
- For date and timestamp values, the
+ For timestamp with time zone values, the
number of seconds since 1970-01-01 00:00:00 UTC (can be negative);
+ for date and timestamp values, the
+ number of seconds since 1970-01-01 00:00:00 local time;
for interval values, the total number
of seconds in the interval
diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c
index 9a7238be38..a3e1e94a2b 100644
--- a/src/backend/utils/adt/timestamp.c
+++ b/src/backend/utils/adt/timestamp.c
@@ -4066,32 +4066,13 @@ timestamp_part(PG_FUNCTION_ARGS)
switch (val)
{
case DTK_EPOCH:
- {
- int tz;
- TimestampTz timestamptz;
-
- /*
- * convert to timestamptz to produce consistent results
- */
- if (timestamp2tm(timestamp, NULL, tm, &fsec, NULL, NULL) != 0)
- ereport(ERROR,
- (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
- errmsg("timestamp out of range")));
-
- tz = DetermineTimeZoneOffset(tm, session_timezone);
-
- if (tm2timestamp(tm, fsec, &tz, ×tamptz) != 0)
- ereport(ERROR,
- (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
- errmsg("timestamp out of range")));
-
#ifdef HAVE_INT64_TIMESTAMP
- result = (timestamptz - SetEpochTimestamp()) / 1000000.0;
+ result = (timestamp - SetEpochTimestamp()) / 1000000.0;
#else
- result = timestamptz - SetEpochTimestamp();
+ result = timestamp - SetEpochTimestamp();
#endif
break;
- }
+
case DTK_DOW:
case DTK_ISODOW:
if (timestamp2tm(timestamp, NULL, tm, &fsec, NULL, NULL) != 0)