Not just for Delphi, but any environment: Why You Should Use NowUTC Instead of Now in Delphi: A Quick Guide
Posted by jpluimers on 2025/07/30
The video is from a while back, but very relevant and shows in Delphi what I have been advocating to software developers for a very long time:
- when timestamping use UTC
- when storing the timestamp store both the UTC timestamp and optionally the UTC timezone/offset and optionally daylight saving indicator of the region it was recorded from
This holds for any environment, so .NET / C#, Python, Delphi and many others as well:
- [Wayback/Archive] DateTime.UtcNow Property (System) | Microsoft Learn
- [Wayback/Archive] What’s New In Python 3.12 — Python 3.13.2 documentation
datetime:datetime.datetime’sutcnow()andutcfromtimestamp()are deprecated and will be removed in a future version. Instead, use timezone-aware objects to represent datetimes in UTC: respectively, callnow()andfromtimestamp()with the tz parameter set todatetime.UTC. (Contributed by Paul Ganssle in gh-103857.)
JavaScript is one of the exceptions, as at the heart, timestamp handling is UTC based:
- [Wayback/Archive] Date – JavaScript | MDN
A JavaScript date is fundamentally specified as the time in milliseconds that has elapsed since the epoch, which is defined as the midnight at the beginning of January 1, 1970, UTC (equivalent to the UNIX epoch). This timestamp is timezone-agnostic and uniquely defines an instant in history.
…
Date.now()- Returns the numeric value corresponding to the current time—the number of milliseconds since January 1, 1970 00:00:00 UTC, with leap seconds ignored.
- [Wayback/Archive] timezone – How do I get a UTC Timestamp in JavaScript? – Stack Overflow (thanks [Wayback/Archive] Merc and [Wayback/Archive] Amadan):
C
This is an old question that came up in my feed today, and it’s full of misinformation. Timestamp is always in UTC.
new Date().toString()will show you current time zone time representation,new Date().toUTCString()will show you UTC time repr, butnew Date().getTime()is always UTC, because that is what Unix time is defined as: “Unix time (also known as POSIX time or epoch time) is a system for describing instants in time, defined as the number of seconds that have elapsed since 00:00:00 Coordinated Universal Time (UTC), Thursday, 1 January 1970, not counting leap seconds.” - [Wayback/Archive] timezone – Getting the client’s time zone (and offset) in JavaScript – Stack Overflow (thanks [Wayback/Archive] Árvíztűrő tükörfúrógép and [Wayback/Archive] PD81)
Q
How can I gather the visitor’s time zone information?
I need both:
- the time zone (for example, Europe/London)
- and the offset from UTC or GMT (for example, UTC+01)
A
To get the system’s IANA timezone in JavaScript, you should use
console.log(Intl.DateTimeFormat().resolvedOptions().timeZone)As of April 2023, this works in 95.42% of the browsers used globally.
[Wayback/Archive] JavaScript built-in: Intl: DateTimeFormat: resolvedOptions: computed `timeZone` | Can I use… Support tables for HTML5, CSS3, etc
[Wayback/Archive] Why You Should Use NowUTC Instead of Now in Delphi: A Quick Guide – YouTube
--jeroen






Leave a comment