Show the epoch
Choose popular date libraries used by your language and show the epoch those libraries use. A demonstration is preferable (e.g. setting the internal representation of the date to 0 ms/ns/etc., or another way that will still show the epoch even if it is changed behind the scenes by the implementers), but text from (with links to) documentation is also acceptable where a demonstration is impossible/impractical. For consistency's sake, show the date in UTC time where possible.
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:
<lang j> 6!:0 2011 8 8 20 25 44.725</lang>
(August 8, 2011, 8:25:44 pm)
That said, the 'dates'
library does have an epoch:
<lang j> require'dates'
todate 0
1800 1 1</lang>
Java
DateFormat
is needed to set the timezone. Printing date
alone would show this date in the timezone/locale of the machine that the program is running on. The epoch used in java.util.Date
is actually in GMT, but there isn't a significant difference between that and UTC for lots of applications (documentation for java.util.Date).
<lang java>import java.text.DateFormat;
import java.util.Date;
import java.util.TimeZone;
public class DateTest{
public static void main(String[] args) { Date date = new Date(0); DateFormat format = DateFormat.getDateTimeInstance(); format.setTimeZone(TimeZone.getTimeZone("UTC")); System.out.println(format.format(date)); }
}</lang> Output:
Jan 1, 1970 12:00:00 AM
Perl
<lang perl>print scalar gmtime 0, "\n";</lang>
Output:
Thu Jan 1 00:00:00 1970
PowerShell
PowerShell uses .NET's DateTime
structure and an integer can simply be casted appropriately:
<lang powershell>[datetime] 0</lang>
Output:
Monday, January 01, 0001 12:00:00 AM
Python
<lang python>>>> import time >>> time.asctime(time.gmtime(0)) 'Thu Jan 1 00:00:00 1970' >>></lang>
Ruby
<lang ruby>irb(main):001:0> Time.at(0).utc => 1970-01-01 00:00:00 UTC</lang>