Reputation: 40668
It feels to me like everywhere I've seen time related algorithms in programming, GMT was the base time. For example, I was told to always store time in a DB in GMT+00 so that time zone changes don't disrupt anything.
Am I right that GMT seems to be the base time zone in software development?
If so, why not UTC? Why is it not common to say "UTC+01" instead of "GMT+01" considering that even Unix timestamps are defined from UTC (http://en.wikipedia.org/wiki/Unix_time)
Upvotes: 10
Views: 18114
Reputation: 219325
I thought it would be fun to discover what IANA timezones are currently using the abbreviation "GMT", both now and 6 months from now (to catch those currently on daylight saving time).
Using this free, open source C++11/14 library, I wrote this program:
#include "tz.h"
#include <string>
#include <iostream>
#include <vector>
template <class Duration>
std::vector<date::zoned_time<std::common_type_t<Duration, std::chrono::seconds>>>
find_by_abbrev(date::sys_time<Duration> tp, const std::string& abbrev)
{
using namespace std::chrono;
using namespace date;
std::vector<zoned_time<std::common_type_t<Duration, seconds>>> results;
auto& db = get_tzdb();
for (auto& z : db.zones)
{
if (z.get_info(tp).abbrev == abbrev)
results.push_back(make_zoned(&z, tp));
}
return results;
}
int
main()
{
using namespace std::chrono;
using namespace date;
auto now = system_clock::now();
auto v = find_by_abbrev(now, "GMT");
for (auto const& x : v)
std::cout << format("%F %H:%M:%S %Z %z", x) << " "
<< x.get_time_zone()->name() << '\n';
std::cout << '\n';
v = find_by_abbrev(now + months{6}, "GMT");
for (auto const& x : v)
std::cout << format("%F %H:%M:%S %Z %z", x) << " "
<< x.get_time_zone()->name() << '\n';
}
This searches the planet for all timezones that are currently using "GMT", both now, and 6 months from now, and prints them out:
2016-06-18 01:00:25.632773 GMT +0000 Africa/Abidjan
2016-06-18 01:00:25.632773 GMT +0000 Africa/Accra
2016-06-18 01:00:25.632773 GMT +0000 Africa/Bissau
2016-06-18 01:00:25.632773 GMT +0000 Africa/Monrovia
2016-06-18 01:00:25.632773 GMT +0000 America/Danmarkshavn
2016-06-18 01:00:25.632773 GMT +0000 Atlantic/Reykjavik
2016-06-18 01:00:25.632773 GMT +0000 Etc/GMT
2016-12-17 15:55:01.632773 GMT +0000 Africa/Abidjan
2016-12-17 15:55:01.632773 GMT +0000 Africa/Accra
2016-12-17 15:55:01.632773 GMT +0000 Africa/Bissau
2016-12-17 15:55:01.632773 GMT +0000 Africa/Monrovia
2016-12-17 15:55:01.632773 GMT +0000 America/Danmarkshavn
2016-12-17 15:55:01.632773 GMT +0000 Atlantic/Reykjavik
2016-12-17 15:55:01.632773 GMT +0000 Etc/GMT
2016-12-17 15:55:01.632773 GMT +0000 Europe/Dublin
2016-12-17 15:55:01.632773 GMT +0000 Europe/London
I was gratified to see that in all cases the UTC offset was +0000
. You never know with politicians and timezones. Some legislative body could easily proclaim "Green Mountain Time" (and just might tomorrow).
Upvotes: 3
Reputation: 29
GMT and UTC are not the same thing. Read https://en.wikipedia.org/wiki/Greenwich_Mean_Time and the link in there to UTC for the distinctions.
Some computer users are confused by the fact that until Windows 7, no Microsoft operating system fully supported UTC, and thus kept labeling the international time reference as GMT.
The key issue is how Windows reads and sets the BIOS clock. Windows XP can't handle setting the BIOS clock to UTC, so you must set the BIOX clock to local time, and then rely on Windows keeping track of the difference.
As of Windows 7, Windows can handle setting the BIOS clock to UTC and does all of the calculations (mostly?) consistent with UTC, so Microsoft decided to switch the label from GMT to UTC.
See:
https://superuser.com/questions/185773/does-windows-7-support-utc-as-bios-time
Upvotes: 2
Reputation: 2636
This accepted response is actually wrong. First they are not the same by any means. Second UTC is NOT more closely in line with "true" time based off of earth's rotation, is exactly the opposite. UTC is more precise in terms of 'time' measure. Each second last the same since is based on atomic time and the precision is increidble hight (it would take 30 thousand years to offset one second).
GMT instead tracks earth rotation, since this is not always the same (the earth rotation is slowing down) each second differs. Of course, differs in a really small ammount of time. But for cientific purposes, is a lot more accurate UTC than GMT.
This is the reason why UTC changes +2 seconds every 4/5 years (since earth rotation is slower each second it takes to rotate has to be bigger than UTC), so it follows GMT earth rotation time by less than a second of difference.
Upvotes: 8
Reputation: 5862
GMT and UTC are the same time. UNIX time is based off of UTC, so you might find that more on UNIX and *nix systems.
UTC is also more closely tracked as an official time (i.e. is more closely in line with "true" time based off of earth's rotation). But unless your software needs to-the-second calculations, it shouldn't make a difference whether you use GMT or UTC.
Although, you might consider which to display to users. One format may be more familiar than another. I would typically go with UTC for global applications, and GMT for European or UK-based applications.
Upvotes: 7
Reputation: 1557
I would say that it is because most people are used to GMT. If you're going to display information to a person, specifically time, you would want a format they can easily understand. Using GMT saves you the extra steps of converting to UTC and back.
Upvotes: 1