A terrible date picker implemented as a 2D driving game where your score is an epoch timestamp that increases as you drive forward.
- Open
index.htmlin a web browser - Use arrow keys to drive: β accelerate, β brake (or reverse if enabled), β β dodge
- Output timestamp increases as you drive (or decreases in reverse)
Drop this into any HTML page:
<script src="epoch-express.js"></script>
<epoch-express id="myDatePicker"></epoch-express>const picker = document.getElementById("myDatePicker");
// Get the selected date
const selectedDate = picker.value; // Returns a Date object
// Listen for date changes (fires every 0.5 seconds while driving)
picker.addEventListener("dateselected", (e) => {
console.log("Date:", e.detail.date);
});
// Reset the game
picker.reset();
// Select current date programmatically (bypasses update interval)
picker.selectCurrentDate();picker.value: Returns the current selected date as a Date objectpicker.reset(): Resets the game to timestamp 0picker.selectCurrentDate(): Immediately fires thedateselectedevent with the current timestamp, bypassing the update interval timer
<epoch-express
days-per-second="350"
update-interval="500"
car-color="#bada55"
difficulty="normal"
reverse="false"
>
</epoch-express>days-per-second(number): How many days pass per second of driving. Higher values = faster time progression. Default: 350update-interval(number): How often the 'dateselected' event fires in milliseconds. Lower values = more frequent updates. Default: 500car-color(string): Custom car color as a hex color code. Default: "#bada55"difficulty(string): Game difficulty level affecting obstacle spawn rate. Options: "easy", "normal", "hard". Default: "normal"reverse(boolean): Enable reverse driving. When true, β key drives backward in time at 1/3 max speed. When false, β key brakes. Default: false