Show the epoch: Difference between revisions
m
→{{header|Wren}}: Minor tidy
(Added AppleScript.) |
m (→{{header|Wren}}: Minor tidy) |
||
(19 intermediate revisions by 15 users not shown) | |||
Line 14:
=={{header|ABAP}}==
<
lv_date = 0.
WRITE: / lv_date.
</syntaxhighlight>
{{out}}
<pre>
Line 25:
</pre>
===Simplified===
<
</syntaxhighlight>
{{out}}
<pre>
Line 36:
However, conversion from unix epoch seconds is also supported and shown below.
<
with Ada.Calendar; use Ada.Calendar;
with Ada.Calendar.Formatting; use Ada.Calendar.Formatting;
Line 44:
begin
Put_Line (Image (Date => etime));
end ShowEpoch;</
{{out}}
<pre>1970-01-01 00:00:00</pre>
Line 52:
There are no fewer than three epochs associated with Mac OS. The original was 1st January 1904 00:00:00. This is stated in the 1999 AppleScript Language Guide, but I don't recall there ever having been a way to find it out by script and I don't think time zone was considered. Mac OS X was introduced in 2001 with a "Cocoa" framework whose epoch was the first instant (UTC) of that year and "underlying UNIX functionality". The <tt>do shell script</tt> added to AppleScript later that year made it possible for scripts to discover the Unix epoch. Since Mac OS X 10.9 (for library scripts) and Mac OS 10.10 (for running scripts), AppleScript's been able to access parts of the Cocoa system without needing add-ons and is thereby able to get the Cocoa epoch.
<
use framework "Foundation"
use scripting additions
local
-- Get the date 0 seconds from the Cocoa epoch.
set
-- The way it's rendered in its 'description' is good enough for the current purpose.
set
-- Get the date 0 seconds from the Unix epoch and format it in the same way.
set UnixEpoch to (do shell script "date -ur 0 '+%F %T %z'")
return "Cocoa epoch: " &
{{output}}
<
Unix epoch: 1970-01-01 00:00:00 +0000"</
=={{header|Arturo}}==
<syntaxhighlight lang="rebol">print to :date 0 ; convert UNIX timestamp: 0 to date
print now
print to :integer now ; convert current date to UNIX timestamp</syntaxhighlight>
{{out}}
<pre>1970-01-01T01:00:00+01:00
2021-05-22T09:27:18+02:00
1621668438</pre>
=={{header|AWK}}==
<syntaxhighlight lang="awk">
# syntax: GAWK -f SHOW_THE_EPOCH.AWK
# requires GNU Awk 4.0.1 or later
Line 80 ⟶ 93:
exit(0)
}
</syntaxhighlight>
{{out}}
<pre>
Line 88 ⟶ 101:
=={{header|BBC BASIC}}==
{{works with|BBC BASIC for Windows}}
<
PRINT FN_date$(0, "dd-MMM-yyyy")</
'''Output:'''
<pre>
Line 96 ⟶ 109:
=={{header|C}}==
<
#include <stdio.h>
Line 103 ⟶ 116:
printf("%s", asctime(gmtime(&t)));
return 0;
}</
{{out}}
<pre>Thu Jan 1 00:00:00 1970</pre>
Line 109 ⟶ 122:
FileTime, from the Win32 API, uses a different epoch.
{{libheader|Win32}}
<
#include <stdio.h>
#include <wchar.h>
Line 142 ⟶ 155:
wprintf(L"FileTime epoch is %ls, at %ls (UTC).\n", date, time);
return 0;
}</
{{out}}
<pre>FileTime epoch is Monday, January 01, 1601, at 12:00:00 AM (UTC).</pre>
=={{header|C sharp|C#}}==
<
class Program
Line 155 ⟶ 168:
Console.WriteLine(new DateTime());
}
}</
{{out}}
<pre>1-1-0001 0:00:00</pre>
Line 163 ⟶ 176:
{{works with|gcc|4.5.3}}
Doesn't work with MSVC 10 SP1
<
#include <chrono>
#include <ctime>
Line 172 ⟶ 185:
std::cout << std::asctime(std::gmtime(&t)) << '\n';
return 0;
}</
{{out}}
<pre>Thu Jan 1 00:00:00 1970</pre>
{{libheader|boost}}
<
#include <boost/date_time.hpp>
int main()
Line 182 ⟶ 195:
std::cout << boost::posix_time::ptime( boost::posix_time::min_date_time ) << '\n';
return 0;
}</
{{out}}
<pre>1400-Jan-01 00:00:00</pre>
=={{header|Clojure}}==
<
Output (since Clojure 1.5)
<syntaxhighlight lang="text">#inst "1970-01-01T00:00:00.000-00:00"</
=={{header|COBOL}}==
<
PROGRAM-ID. epoch.
Line 208 ⟶ 221:
GOBACK
.</
{{out}}
Line 214 ⟶ 227:
=={{header|CoffeeScript}}==
<
{{out}}
<pre>Thu, 01 Jan 1970 00:00:00 GMT</pre>
=={{header|Common Lisp}}==
<
(format t "~4,'0D-~2,'0D-~2,'0D ~2,'0D:~2,'0D:~2,'0D" year month day hour minute second))</
{{out}}
<pre>1900-01-01 00:00:00</pre>
Line 228 ⟶ 241:
=={{header|Dart}}==
<
print(new Date.fromEpoch(0,new TimeZone.utc()));
}</
{{out}}
<pre>1970-01-01 00:00:00.000Z</pre>
=={{header|Delphi}}==
<
{$APPTYPE CONSOLE}
Line 243 ⟶ 256:
begin
Writeln(FormatDateTime('yyyy-mm-dd hh:nn:ss.zzz', 0));
end.</
{{out}}
<pre>1899-12-30 00:00:00.000</pre>
Line 262 ⟶ 275:
=={{header|F_Sharp|F#}}==
<
{{out}}
<pre>0001-01-01 00:00:00Z</pre>
=={{header|Factor}}==
<
0 micros>timestamp timestamp>ymdhms print</
{{out}}
<pre>
Line 277 ⟶ 290:
=={{header|Forth}}==
{{works with|4tH|3.61.3}}
<
0 posix>jday .longjday cr</
{{out}}
<pre>
Line 293 ⟶ 306:
Date/time values in FB are always based on the current regional settings and so, if values are needed for other time-zones (or UTC), the appropriate adjustments must be made.
<
#Include "vbcompat.bi"
Line 308 ⟶ 321:
Print
Print "Press any key to quit"
Sleep</
{{out}}
Line 318 ⟶ 331:
December 17, 1680 00:00:00
</pre>
=={{header|Frink}}==
Internally, Frink references all date/time values as a number of seconds relative to Julian Day 0 referenced to UTC. The internal numeric type is Frink's "do the right thing" numeric type which can be exact rational numbers, arbitrary-precision floating-point numbers, or even intervals, which gives essentially arbitrary precision and exact round-trip capability to any date/time value stored. These are transparently converted to arbitrary timezones or date systems for display.
<syntaxhighlight lang="frink">println[ JD[0 s] -> UTC ]</syntaxhighlight>
{{out}}
<pre>
BC 4713-01-01 PM 12:00:00.000 (Mon) Coordinated Universal Time
</pre>
Frink also makes it easy to work with date/time values referenced to any arbitrary epoch. For example, to find the number of nanoseconds since the UNIX epoch:
<syntaxhighlight lang="frink">epoch = # 1970 UTC #
now[] - epoch -> ns
</syntaxhighlight>
{{out}}
<pre>
1665439770353000000
</pre>
Or to add a number of seconds to the UNIX epoch and find the result in Japan's timezone:
<syntaxhighlight lang="frink">epoch = # 1970 UTC #
epoch + 2 billion seconds -> Japan
</syntaxhighlight>
{{out}}
<pre>
AD 2033-05-18 PM 12:33:20.000 (Wed) Japan Standard Time
</pre>
Leap seconds are usually not taken into account in these calculations, but they can be easily using [https://frinklang.org/#LeapSeconds Frink's leap-second functions.]
=={{header|FutureBasic}}==
<
print date$
Line 336 ⟶ 374:
print
print time$("h:mm a ZZZZ "); date$("MMMM d, yyyy G")
HandleEvents</syntaxhighlight>
Output:
<pre>
Line 355 ⟶ 394:
=={{header|Go}}==
<
import ("fmt"; "time")
func main() {
fmt.Println(time.Time{})
}</
{{out}}
This is UNIX format. The 1 on the end is the full year, not two or four digit year.
Line 369 ⟶ 408:
=={{header|Groovy}}==
Groovy uses the UNIX epoch.
<
def format = new java.text.SimpleDateFormat('yyyy-MM-dd\'T\'HH:mm:ss.SSSZ')
format.timeZone = TimeZone.getTimeZone('UTC')
println (format.format(date))</
{{out}}
<pre>1970-01-01T00:00:00.000+0000</pre>
Line 380 ⟶ 419:
The <code>ClockTime</code> type is abstract in Haskell 98, but is defined in GHC.
{{works with|GHC}}
<
main = putStrLn $ calendarTimeToString $ toUTCTime $ TOD 0 0</
{{out}}
<pre>Thu Jan 1 00:00:00 UTC 1970</pre>
===New time library===
{{works with|GHC}}
<
main = print $ UTCTime (ModifiedJulianDay 0) 0</
{{out}}
<pre>1858-11-17 00:00:00 UTC</pre>
Line 405 ⟶ 444:
* [http://www.cs.arizona.edu/icon/library/src/procs/datetime.icn datetime routines] use a global variable 'DateBaseYear' which defaults to Jan 1, 1970 00:00:00 but can be set if desired.
* The example below uses only a couple of the datetime procedures
<
procedure main()
Line 416 ⟶ 455:
now := DateToSec(&date) + ClockToSec(&clock)
printf("Now is also %s and %s\n",SecToDate(now),SecToDateLine(now))
end</
{{out|Sample Output}}
<pre>&now and gettimeofday().sec are equal
Line 425 ⟶ 464:
=={{header|J}}==
J does not have an epoch. J's native representation of date and time is a six element list: year, month, day, hour, minute, second. For example:
<
2011 8 8 20 25 44.725</
(August 8, 2011, 8:25:44 pm)
That said, the <code>'dates'</code> library does have an epoch:
<
todate 0
1800 1 1</
=={{header|Java}}==
<code>DateFormat</code> is needed to set the timezone. Printing <code>date</code> alone would show this date in the timezone/locale of the machine that the program is running on. The epoch used in <code>java.util.Date</code> (as well as <code>java.sql.Date</code>, which can be subbed into this example) is actually in GMT, but there isn't a significant difference between that and UTC for lots of applications ([http://download.oracle.com/javase/7/docs/api/java/util/Date.html#getTime() documentation for java.util.Date]).
<
import java.util.Date;
import java.util.TimeZone;
Line 447 ⟶ 486:
System.out.println(format.format(date));
}
}</
{{out}}
<pre>Jan 1, 1970 12:00:00 AM</pre>
On my PC I see
<pre>01.01.1970 00:00:00</pre>
===Using Java 8===
Java 8 introduced the classes LocalDate, LocalTime, LoclDateTime,
and other associated classes which simplified the manipulation of dates and times.
<syntaxhighlight lang = "java">
import java.time.LocalDateTime;
import java.time.ZoneOffset;
public final class ShowTheEpoch {
public static void main(String[] args) {
System.out.println(LocalDateTime.ofEpochSecond(0, 0, ZoneOffset.UTC));
}
}
</syntaxhighlight>
{{ out }}
<pre>
1970-01-01T00:00
</pre>
=={{header|JavaScript}}==
<
{{out}}
<pre>Thu, 01 Jan 1970 00:00:00 GMT</pre>
=={{header|Joy}}==
<syntaxhighlight lang="joy">0 gmtime "%Y-%m-%d %H:%M:%S" strftime.</syntaxhighlight>
{{out}}
<pre>"1970-01-01 00:00:00"</pre>
=={{header|jq}}==
<syntaxhighlight lang
{{out}}
<
=={{header|Julia}}==
{{works with|Julia|0.6}}
<
println("Time zero (the epoch) is $(unix2datetime(0)).")</
{{out}}
Line 474 ⟶ 539:
=={{header|Kotlin}}==
{{trans|Java}}
<
import java.util.Date
Line 485 ⟶ 550:
format.timeZone = TimeZone.getTimeZone("UTC")
println(format.format(epoch))
}</
{{out}}
Line 493 ⟶ 558:
=={{header|Lasso}}==
<
date(0)</
{{out}}
Line 501 ⟶ 566:
=={{header|Limbo}}==
<
include "sys.m"; sys: Sys;
Line 517 ⟶ 582:
daytime = load Daytime Daytime->PATH;
sys->print("%s\n", daytime->text(daytime->gmt(0)));
}</
Of course, this could also be done by mangling the namespace and forging the current date, locking it to the epoch:
<
include "sys.m"; sys: Sys;
Line 555 ⟶ 620:
sys->print("%s\n", daytime->text(daytime->gmt(daytime->now())));
}
</syntaxhighlight>
{{out}}
Line 565 ⟶ 630:
Lingo's date object is not based on an epoch, but instead on runtime date calculations. A new date object is created by specifying "year, month, day", based on gregorian calendar. In arithmetic context, date objects are casted to "days" (AD), not to seconds or milliseconds (see below).
<
put now
-- date( 2018, 3, 21 )
Line 573 ⟶ 638:
-- print approx. year difference between "babylonianDate" and now
put (now-babylonianDate)/365.2425
-- 3818.1355</
=={{header|LiveCode}}==
LiveCode uses midnight, January 1, 1970 as the start of the eon
<
convert somedate to internet date
put somedate
Line 583 ⟶ 648:
-- output GMT (localised)
-- Thu, 1 Jan 1970 10:00:00 +1000
</syntaxhighlight>
=={{header|LotusScript}}==
Uses LotusScript to calculate difference between current time and epoch start date. This example: a button which prints the result. Of course, change the <code>timeStamp</code> variable to whatever suits your need.
<
Sub Click(Source As Button)
'Create timestamp as of now
Line 606 ⟶ 671:
End Sub
</syntaxhighlight>
Output:
Line 614 ⟶ 679:
=={{header|Lua}}==
<
{{out}}
<pre>Thu Jan 1 00:00:00 1970</pre>
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<syntaxhighlight lang
{{out}}
<pre>Mon 1 Jan 1900 00:00:00</pre>
=={{header|MATLAB}} / {{header|Octave}}==
Matlab and Octave store date/time number in a floating point number counting the days.
<
for k=1:length(d)
printf('day %f\t%s\n',d(k),datestr(d(k),0))
disp(datevec(d(k)))
end;</
{{out}}
<pre>day 0.000000 31-Dec--001 00:00:00
Line 655 ⟶ 721:
=={{header|Maxima}}==
<
"1900-01-01 10:00:00+10:00"</
=={{header|min}}==
<syntaxhighlight lang="min">0 datetime puts!</syntaxhighlight>
{{out}}
<pre>
1970-01-01T00:00:00Z
</pre>
=={{header|NetRexx}}==
{{trans|Java}}
<
options replace format comments java crossref symbols nobinary
Line 670 ⟶ 743:
say zulu.format(edate)
return
</syntaxhighlight>
'''Output:'''
<pre>
Line 677 ⟶ 750:
=={{header|NewLISP}}==
<
->"Thu Jan 01 01:00:00 1970"</
=={{header|Nim}}==
Nim “times” module provides procedures to convert to and from timestamps. Using these procedures, it’s easy to find the epoch, even on another system:
<syntaxhighlight lang="nim">import times
echo "Epoch for Posix systems: ", fromUnix(0).utc
echo "Epoch for Windows system: ", fromWinTime(0).utc</syntaxhighlight>
{{out}}
<pre>Epoch for Posix systems: 1970-01-01T00:00:00Z
Epoch for Windows system: 1601-01-01T00:00:00Z</pre>
=={{header|Objective-C}}==
<
int main(int argc, const char *argv[]) {
Line 701 ⟶ 778:
}
return 0;
}</
{{out|Log}}
<pre>2001-01-01 00:00:00 +0000</pre>
=={{header|OCaml}}==
<
let months = [| "January"; "February"; "March"; "April"; "May"; "June";
Line 713 ⟶ 790:
let () =
let t = Unix.gmtime 0.0 in
Printf.printf "%s %d, %d\n" months.(t.tm_mon) t.tm_mday (1900 + t.tm_year)</
{{out|Execution}}
<pre>$ ocaml unix.cma epoch.ml
Line 720 ⟶ 797:
=={{header|Oforth}}==
<
0 asDateUTC println</
{{out}}
Line 731 ⟶ 808:
=={{header|PARI/GP}}==
GP has no built-in date or time system.
<
PARI, as usual, has access to the same resources as [[#C|C]].
Line 737 ⟶ 814:
=={{header|Pascal}}==
This works with [[Free_Pascal| Free Pascal]]:
<
uses
Line 745 ⟶ 822:
Writeln(FormatDateTime('yyyy-mm-dd hh:nn:ss.zzz', Now));
Writeln(FormatDateTime('yyyy-mm-dd hh:nn:ss.zzz', 0));
end.</
{{out}}
<pre>
Line 754 ⟶ 831:
=={{header|Perl}}==
<
{{out}}
<pre>Thu Jan 1 00:00:00 1970</pre>
Line 760 ⟶ 837:
=={{header|Phix}}==
The standard Phix file builtins/datetime.e does not use an epoch, but instead expects absolute values, eg Jan 1st 1970 is {1970,1,1,...}. I suppose the closest we can get is:
<!--<syntaxhighlight lang="phix">(phixonline)-->
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">constant</span> <span style="color: #000000;">d0</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #000000;">1</span><span style="color: #0000FF;">}</span>
<span style="color: #008080;">include</span> <span style="color: #000000;">builtins</span><span style="color: #0000FF;">\</span><span style="color: #004080;">timedate</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span>
<span style="color: #0000FF;">?</span><span style="color: #7060A8;">format_timedate</span><span style="color: #0000FF;">(</span><span style="color: #000000;">d0</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"YYYY-MM-DD"</span><span style="color: #0000FF;">)</span>
<span style="color: #0000FF;">?</span><span style="color: #7060A8;">format_timedate</span><span style="color: #0000FF;">(</span><span style="color: #000000;">d0</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Dddd, Mmmm d, YYYY"</span><span style="color: #0000FF;">)</span>
<!--</syntaxhighlight>-->
<pre>
"0000-01-01"
Line 772 ⟶ 852:
=={{header|PHP}}==
<
echo gmdate('r', 0), "\n";
?></
{{out}}
<pre>Thu, 01 Jan 1970 00:00:00 +0000</pre>
Line 780 ⟶ 860:
=={{header|PicoLisp}}==
The 'date' function in PicoLisp returns a day number, starting first of March of the year zero. Calculated according to the gregorian calendar (despite that that calendar wasn't used in 0 AD yet).
<
-> (0 3 1) # Year zero, March 1st</
=={{header|Pike}}==
The usual localtime() method for simple time extraction is available, but the built in Calendar module is a more diverse tool.
<syntaxhighlight lang="pike">
object cal = Calendar.ISO->set_timezone("UTC");
write( cal.Second(0)->format_iso_short() );
</syntaxhighlight>
{{Out}}
<pre>19700101T00:00:00</pre>
=={{header|PL/I}}==
<
epoch: Proc Options(main);
/*********************************************************************
Line 809 ⟶ 889:
Put Edit(d ,days(d))
(Skip,a,f(15));
End;</
Result:
<pre>
Line 822 ⟶ 902:
=={{header|PowerShell}}==
PowerShell uses .NET's <code>DateTime</code> structure and an integer can simply be casted appropriately:
<syntaxhighlight lang
{{out}}
<pre>Monday, January 01, 0001 12:00:00 AM</pre>
Line 828 ⟶ 908:
===Three Alternates===
<code>Get-Date</code> always returns its '''Kind''' property as Local:
<syntaxhighlight lang="powershell">
Get-Date -Year 1 -Month 1 -Day 1 -Hour 0 -Minute 0 -Second 0 -Millisecond 0
</syntaxhighlight>
{{Out}}
<pre>
Line 836 ⟶ 916:
</pre>
This approach returns its '''Kind''' property as Unspecified:
<syntaxhighlight lang="powershell">
New-Object -TypeName System.DateTime
</syntaxhighlight>
{{Out}}
<pre>
Line 845 ⟶ 925:
Here you could describe the epoch date's '''Kind''' property as being Utc.
Formatting the output as a list for demonstration:
<syntaxhighlight lang="powershell">
New-Object -TypeName System.DateTime -ArgumentList 1, 1, 1, 0, 0, 0, ([DateTimeKind]::Utc) | Format-List
</syntaxhighlight>
{{Out}}
<pre>
Line 867 ⟶ 947:
=={{header|PureBasic}}==
<
PrintN(FormatDate("Y = %yyyy M = %mm D = %dd, %hh:%ii:%ss", 0))
Print(#CRLF$ + #CRLF$ + "Press ENTER to exit"): Input()
CloseConsole()
EndIf</
{{out}}
<pre>Y = 1970 M = 01 D = 01, 00:00:00</pre>
=={{header|Python}}==
<
>>> time.asctime(time.gmtime(0))
'Thu Jan 1 00:00:00 1970'
>>></
=={{header|R}}==
<
> class(epoch) <- class(Sys.time())
> format(epoch, "%Y-%m-%d %H:%M:%S %Z")
[1] "1970-01-01 00:00:00 UTC"</
=={{header|Racket}}==
<
#lang racket
(require racket/date)
(date->string (seconds->date 0 #f))
</syntaxhighlight>
Output:
Line 902 ⟶ 982:
=={{header|Raku}}==
(formerly Perl 6)
<syntaxhighlight lang="raku"
{{out}}
<pre>
Line 910 ⟶ 990:
=={{header|REXX}}==
The epoch for the REXX language BIF (<u>B</u>uilt-<u>I</u>n <u>F</u>unction) '''DATE''' is: January 1st, year 1.
<
say ' today is: ' date() /*today's is format: mm MON YYYY */
Line 920 ⟶ 1,000:
/* ↑ ┌───◄─── This BIF (Built-In Function) is only */
/* └─────────◄──────┘ for newer versions of REXX that */
/* support the 2nd and 3rd arguments. */</
{{output|out}}
<pre>
Line 929 ⟶ 1,009:
=={{header|Ring}}==
<
load "guilib.ring"
Line 944 ⟶ 1,024:
exec()
}
</syntaxhighlight>
Output:
[[File:CalmoSoftShowEpoch.jpg]]
=={{header|RPL}}==
RPL can not go back into the past beyond 15 October 1582.
15.101582 -1 DATE+
{{out}}
<pre>
DATE+ Error:
Bad Argument Value
</pre>
=={{header|Ruby}}==
<
=> 1970-01-01 00:00:00 UTC</
The Date class however uses the Julian date -4712-1-1 as default when no parameters are supplied
<
Date.new # => #<Date: -4712-01-01 ((0j,0s,0n),+0s,2299161j)>
</syntaxhighlight>
=={{header|Run BASIC}}==
<
cDate$ = date$(0) ' 01/01/1901
sDate$ = date$("01/01/1970")</
=={{header|Rust}}==
<
use time::{at_utc, Timespec};
Line 970 ⟶ 1,059:
let epoch = at_utc(Timespec::new(0, 0));
println!("{}", epoch.asctime());
}</
{{out}}
<pre>Thu Jan 1 00:00:00 1970</pre>
=={{header|Scala}}==
<
import java.text.DateFormat
val df=DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, Locale.ENGLISH)
df.setTimeZone(TimeZone.getTimeZone("UTC"))
println(df.format(new Date(0)))</
{{out}}
<pre>January 1, 1970 12:00:00 AM UTC</pre>
=={{header|Scheme}}==
{{works with|Chez Scheme}}
<syntaxhighlight lang="scheme">; Display date at Time Zero in UTC.
(printf "~s~%" (time-utc->date (make-time 'time-utc 0 0) 0))</syntaxhighlight>
{{out}}
<pre>
#<date Thu Jan 1 00:00:00 1970>
</pre>
=={{header|Seed7}}==
Line 992 ⟶ 1,089:
negative years exist and that the year preceding 1 is 0.
Therefore the epoch is the beginning of the year 0.
<
include "time.s7i";
Line 998 ⟶ 1,095:
begin
writeln(time.value);
end func;</
{{out}}
<pre>
Line 1,005 ⟶ 1,102:
=={{header|Sidef}}==
<
{{out}}
<pre>Thu Jan 1 00:00:00 1970</pre>
=={{header|Standard ML}}==
<
val it = "Thu Jan 1 00:00:00 1970" : string</
=={{header|Stata}}==
<
01jan1960
. di %tc 0
01jan1960 00:00:00</
=={{header|Tcl}}==
<
Thu Jan 01 00:00:00 GMT 1970</
=={{header|TUSCRIPT}}==
<
- epoch
number=1
Line 1,033 ⟶ 1,130:
dayofweeknr=DATE (today,day,month,year,number)
date=JOIN (year,"-",month,day)
PRINT "today's date: ", date," (daynumber ", number,")"</
{{out}}
<pre>
Line 1,040 ⟶ 1,137:
</pre>
=={{header|uBasic/4tH}}==
uBasic/4tH provides a '''TIME()''' function, which returns the common epoch, but doesn't provide a builtin function to display it - other than it's numerical value. This program shows the epoch in high level code.
<syntaxhighlight lang="text">Print Show(FUNC(_DateStr(0))), Show(FUNC(_TimeStr(0)))
End
_DateStr ' convert epoch to date string
Param (1)
Local (6)
a@ = a@ / 86400 ' just get the number of days since epoch
b@ = 1970+(a@/365) ' ball parking year, will not be accurate!
d@ = 0
For c@ = 1972 To b@ - 1 Step 4
If (((c@%4) = 0) * ((c@%100) # 0)) + ((c@%400) = 0) Then d@ = d@+1
Next
b@ = 1970+((a@ - d@)/365) ' calculating accurate current year by (x - extra leap days)
e@ = ((a@ - d@)%365)+1 ' if current year is leap, set indicator to 1
f@ = (((b@%4) = 0) * ((b@%100) # 0)) + ((b@%400) = 0)
g@ = 0 ' calculating current month
For c@ = 0 To 11 Until e@ < (g@+1)
g@ = g@ + FUNC(_Monthdays (c@, f@))
Next
' calculating current date
g@ = g@ - FUNC(_Monthdays (c@-1, f@))
' Print a@, d@, e@, f@
Return (Join (Str(b@), FUNC(_Format (c@, Dup("-"))), FUNC(_Format (e@ - g@, Dup("-")))))
_TimeStr ' convert epoch to time string
Param (1)
Return (Join(Str((a@%86400)/3600), FUNC(_Format ((a@%3600)/60, Dup(":"))), FUNC(_Format (a@%60, Dup(":")))))
_Format Param (2) : Return (Join (Iif (a@<10, Join(b@, "0"), b@), Str (a@)))
_Monthdays Param (2) : Return (((a@ + (a@<7)) % 2) + 30 - ((2 - b@) * (a@=1)))</syntaxhighlight>
{{Out}}
<pre>
1970-01-01 0:00:00
0 OK, 0:58
</pre>
=={{header|UNIX Shell}}==
The nonstandard option <code>date -r</code> takes seconds from the epoch, and prints date and time. See [http://www.openbsd.org/cgi-bin/man.cgi?query=date&apropos=0&sektion=1&manpath=OpenBSD+Current&arch=i386&format=html date(1) manual].
{{works with|OpenBSD}}
<
Thu Jan 1 00:00:00 UTC 1970</
On systems with GNU date, you can do
<
$ TZ=UTC date --date "$(date +%s) seconds ago"
Thu Jan 1 00:00:00 UTC 1970
</syntaxhighlight>
=={{header|Visual Basic}}==
<
Debug.Print Format(0, "dd mmm yyyy hh:mm")
End Sub</
{{out|Output (in debug window)}}
30 Dec 1899 00:00
Line 1,062 ⟶ 1,201:
{{libheader|Wren-date}}
The epoch (or zero date/time) for the above module is midnight on 1st January, 0001 UTC according to the Gregorian proleptic calendar, though it can also cater for the Unix epoch as well.
<
Date.default = Date.isoFull
Line 1,069 ⟶ 1,208:
var dt2 = Date.unixEpoch
System.print(dt2)</
{{out}}
Line 1,079 ⟶ 1,218:
=={{header|zkl}}==
Using the method tickToTock(time_t,useLocalTime) on Linux. tickToTock converts a time_t (seconds since the epoch) to "human" time. False means use UTC (vs local time, the default).
<
L(1970,1,1,0,0,0) // y,m,d, h,m,s</
Line 1,088 ⟶ 1,227:
{{omit from|Locomotive Basic}}
{{omit from|ZX Spectrum Basic}}
{{omit from|6502 Assembly|Depends entirely on implementation}}
{{omit from|68000 Assembly|Depends entirely on implementation}}
{{omit from|8080 Assembly|Depends entirely on implementation}}
{{omit from|8086 Assembly|Depends entirely on implementation}}
{{omit from|ARM Assembly|Depends entirely on implementation}}
{{omit from|MIPS Assembly|Depends entirely on implementation}}
{{omit from|Z80 Assembly|Depends entirely on implementation}}
|