SELECT extract(epoch FROM date('2000-01-01 12:34')); With timestamp:SELECT EXTRACT(EPOCH FROM TIMESTAMP WITH TIME ZONE '2001-02-16 20:38:40-08'); With interval:SELECT EXTRACT(EPOCH FROM INTERVAL '5 days 3 hours');
date(output format,epoch);Output format example: 'r' = RFC 2822 date
Ruby
Time.at(epoch)
Python
import timefirst, thentime.strftime("%a, %d %b %Y %H:%M:%S +0000", time.localtime(epoch))Replace time.localtime with time.gmtime for GMT time.
Java
String date = new java.text.SimpleDateFormat("MM/dd/yyyy HH:mm:ss").format(new java.util.Date (epoch*1000));
VBscript/ASP
DateAdd("s",epoch, "01/01/1970 00:00:00")
MySQL
from_unixtime(epoch,optional output format)The default output format is YYY-MM-DD HH:MM:SSmore ...
PostgreSQL
PostgreSQL version 8.1 and higher:SELECT to_timestamp(epoch);Older versions:SELECT TIMESTAMP WITH TIME ZONE 'epoch' +epoch* INTERVAL '1 second';
SQL Server
DATEADD(s,epoch, '1970-01-01 00:00:00')
Microsoft Excel
=(A1 / 86400) + 25569Format the result cell for date/time, the result will be in GMT time (A1 is the cell with the epoch number). For other timezones: =((A1 +/-timezone adjustment) / 86400) + 25569.
Crystal Reports
DateAdd("s", {EpochTimeStampField}-14400, #1/1/1970 00:00:00#)-14400 used for Eastern Standard Time. SeeTimezones.
date -d @1190000000Replace 1190000000 with your epoch, needs recent version of 'date'. Replace '-d' with '-ud' for GMT/UTC time.
PowerShell
Function get-epochDate ($epochDate) { [timezone]::CurrentTimeZone.ToLocalTime(([datetime]'1/1/1970').AddSeconds($epochDate)) }, then use:get-epochDate 1279152364. Works for Windows PowerShell v1 and v2
Other OS's
Command line:perl -e "print scalar(localtime(epoch))"(If Perl is installed) Replace 'localtime' with 'gmtime' for GMT/UTC time.