A life in a few lines
22 DEC 1984 · BORN
22 December 1984 is my date of birth. It is the starting point for the count of days lived.
30 JUL 2022 · DUBAI
30 July 2022 marks the start of my life in Dubai. This part of my life has its own counter.
NOW
Today’s date on Dubai time, UTC+4. It changes with the calendar.
LIFE · DAY
The number of complete calendar days since birth. The day of birth is the starting point, day zero.
DUBAI · DAY
The number of days since moving to Dubai.
OF LIFE · DUBAI
Days in Dubai divided by all days lived. This makes the move visible in the span of a whole life.
The code behind these numbers
This function counts days lived, days in Dubai and their share of a lifetime. It also powers the counter above. Copy this working example for your own page and replace the two dates with yours. Calendar days follow Dubai time.
<output id="life-counter" aria-label="Counter code"></output>
<script>
const lifeCounters = function lifeCounters(now, residency, birth, locale, units) {
const parts = Object.fromEntries(new Intl.DateTimeFormat("en-CA", {
timeZone: "Asia/Dubai",
year: "numeric",
month: "2-digit",
day: "2-digit"
}).formatToParts(now).map((p) => [p.type, p.value]));
const day = Date.UTC(+parts.year, +parts.month - 1, +parts.day);
const count = (date) => {
if (!/^\d{4}-\d{2}-\d{2}$/.test(date || "")) throw new Error("Invalid counter date");
return Math.floor((day - Date.parse(date + "T00:00:00Z")) / 864e5);
};
const dubai = count(residency), life = count(birth);
if (!Number.isFinite(dubai) || !Number.isFinite(life) || dubai < 0 || life <= 0) throw new Error("Invalid counter range");
const unit = (n) => units[new Intl.PluralRules(locale).select(n)] || units.other;
const d = Object.fromEntries(new Intl.DateTimeFormat(locale, {
timeZone: "Asia/Dubai",
year: "numeric",
month: "long",
day: "numeric"
}).formatToParts(now).map((p) => [p.type, p.value]));
return {
"data-current-date": ["ru", "en"].includes(locale.split("-")[0]) ? `${d.day} ${d.month} ${d.year}` : new Intl.DateTimeFormat(locale, {
timeZone: "Asia/Dubai",
dateStyle: "long"
}).format(now),
"data-dubai-day-counter": dubai.toLocaleString(locale),
"data-life-day-counter": life.toLocaleString(locale),
"data-dubai-day-unit": unit(dubai),
"data-life-day-unit": unit(life),
"data-dubai-life-share": (dubai / life * 100).toLocaleString(locale, {
minimumFractionDigits: 2,
maximumFractionDigits: 2
}) + "%"
};
};
function updateCounter() {
const counters = lifeCounters(
new Date(), '2022-07-30', '1984-12-22', 'en-US', {other: 'days'}
);
document.getElementById('life-counter').textContent = [
'LIFE · DAY ' + counters['data-life-day-counter'],
'DUBAI · DAY ' + counters['data-dubai-day-counter'],
counters['data-dubai-life-share'] + ' OF LIFE · DUBAI'
].join(' / ');
}
updateCounter();
setInterval(updateCounter, 30000);
</script>
@nevsky_alexander
On Instagram: Dubai beyond the postcard — family, the city, discoveries and life between projects. On Threads: thinking out loud about design and AI. On YouTube: videos that need more room than a story. Follow me wherever you feel at home, and let’s keep in touch