ChatGPT-4: A great tool to aid software development, just don't ask it for help with UNIX timestamps
I'd like to first say that I am on team Chat Gippity, as it is fondly known. I have been so impressed that it is now a full time side kick (until it takes all our jobs) in my day to day activities. The capabilities it possesses continue to surprise and delight, and I find it incredibly useful, in and out of my software development work.
But as has been well mentioned, its responses should never be taken as gospel, and as you should never just blindly copy and paste from StackOverflow, the same applies with Chat Gippity. At the end of the day, they are tools that are only as powerful and useful as the person driving them.
As an example of this, using ChatGPT-4, I presented it with a small amount of tabular data. Two columns, a non-unique id column, and a UNIX timestamp (second precision) last played column:
id last_played
------- -----------
1 1669819873
4 1676381191
5 1671106746
7 1670496178
11 1687354249
15 1681985696
30 1687441966
8 1687771942
2 1669290959
4 1670414093
6 1670415570
10 1673620423
12 1673869519
14 1675264425
2 1684232313
23 1686581557
24 1684232268
4 1669292150
6 1670413781
7 1671105540
8 1670499558
9 1671104989
14 1675175961
20 1681982837
Along with the prompt "Give me the IDs that were last played before 2022-12-08
".
I had to follow up with a second prompt to state the ID column was not unique. The response was then:
id last_played (most recent for each ID)
------- -------------------------------------
1 1669819873
4 1676381191
5 1671106746
6 1670415570
7 1671105540
8 1670499558
9 1671104989
10 1673620423
12 1673869519
14 1675264425
Doing a quick spot check, ID 1
seems correct, as 1669819873
translates to the date 2022-11-30
.
How about ID 4
? - Hmm, 1676381191
translates to the date 2023-02-14
😕. What happened here?
What happened next was a series of prompts and responses from ChatGPT trying to rectify the issue. After several apologies and retries, it just could not calculate the correct output.
Finally, it laid out its calculations:
I apologize for the repeated errors. Let's resolve this.
To calculate the Unix timestamp for 2022-12-08, we'd consider:
2022 years (excluding 1970) is 52 years.
For the Unix timestamp, we typically calculate:
- 365 days for each non-leap year
- 366 days for each leap year
- Additional days for the months of 2022 up to December 7
Leap years between 1970 and 2022: 1972, 1976, 1980, 1984, 1988, 1992, 1996, 2000, 2004, 2008, 2012, 2016, and 2020. That's 13 leap years.
So, we have:
(52 - 13) * 365 + 13 * 366 + (31 (for January) + 28 (for February) + 31 (for March) + 30 (for April) + 31 (for May) + 30 (for June) + 31 (for July) + 31 (for August) + 30 (for September) + 31 (for October) + 30 (for November) + 7 (for December)) = 19232 days since 1970-01-01.
Converting days to seconds:
19232 * 24 * 60 * 60 = 1,661,452,800 seconds.
So, the Unix timestamp for 2022-12-08 00:00:00 UTC should be 1661452800.
There seems to be an issue here, related to the claim that "ChatGPT struggles with maths".
The working out for the number of days seems correct, however:
(52 - 13) * 365 + (13 * 366) + (31+28+31+30+31+30+31+31+30+31+30+7) = 19334
Not 19232
.
With this new value plugged in:
19334 * 24 * 60 * 60 = 1,670,457,600
and the UNIX timestamp 1670457600
does indeed translate to 2022-12-08
Conclusion
ChatGPT-4, like any tool, is not infallible, and this was an interesting experiment with unmeaningful data.
While ChatGPT offers a plethora of possibilities in various fields, relying solely on it without human scrutiny can lead to errors. As AI continues to evolve and integrate deeper into our day-to-day lives, it's pivotal to approach such tools with a balance of enthusiasm and caution. Remember, technology is as effective as the human oversight guiding it. The collaboration of human intellect and AI is where the true potential lies.
Comments ()