JavaScript/Epoch time converter



This epoch time converter can convert dates into Unix epoch time stamps and vice versa. It makes use of the sophisticated date and time parsing abilities included in JavaScript.

The input format is automatically detected. If the input is only numerical without any other characters, it is presumed to be a UNIX epoch time stamp. Otherwise, it is presumed to be a date. A four-digit input value is presumed to be a year.

The script also detects URL hashes (characters after "#" in the URL), which can be used to enter a value as well, and for memorizing the last input. The URL hash will be updated when pressing the ↵ Enter key or clicking the "Auto-detect and convert" button. The result is previewed after each key press.

There are additional buttons for interchanging the input and the result, for calculating the current epoch time stamp, and for clearing the input field. The last adds convenience for mobile users.

The code contains comments to facilitate understanding each part.