Date/Epoch Converter
Current Time (from your computer)
|
Current Date/Time: (JavaScript)
(Sorry, it doesn't appear that your browser currently supports JavaScript.)
|
|
What is Epoch
Epoch has a few meanings (see also
http://dictionary.reference.com/search?q=epoch).
The definition that we'll use is "0" in computer time.
While there are folks who will argue this,
for our purposes, this "0" time on our calendar was
January 1, 1970 00:00:00 GMT. Epoch is useful in the
programming world because it allows us to mathematically
compare dates with other dates or some other measure of time.
Said another way, it allows us to use a programming algorithm
to make decisions regarding a human readable date or time.
How to Convert between Date and Epoch
I've had a number of inquiries into how to do the conversion. I figured folks interested
in that level of detail would use the source code for this page to ascertain the approach used here.
However, I suppose assuming everyone enjoys deciphering the idiosyncrasies of JavaScript for fun
was a bit naive... my bad. I'll take a stab at explaining what the code does.
First off, the easiest way to get the current time in epoch (using JavaScript), is to call getTime()
method of the JavaScript Date object and divide the return value by 1000. getTime returns the number
of milliseconds elapsed, in your computer's timezone, since 1/1/1970 GMT. Because epoch is measured
in seconds, you then want to divide the return value by 1000 to change milliseconds into seconds.
Keep in mind that the JavaScript Date object will get it's time from your computer's clock.
Here's a really simple example doing this.
Source Code for Converter and Examples