1 00:00:00,000 --> 00:00:09,647 [MUSIC] 2 00:00:09,647 --> 00:00:14,250 Hi, I'm Rachel, a Python teacher here at Treehouse. 3 00:00:14,250 --> 00:00:17,929 If you're a programmer, you're going to have to deal with dates or 4 00:00:17,929 --> 00:00:21,170 times eventually, and sometimes, even at the same time. 5 00:00:22,280 --> 00:00:27,241 Now, computers think about time a little differently than we do as humans, so 6 00:00:27,241 --> 00:00:32,052 it's our job as programmers to have an understanding of that before we start 7 00:00:32,052 --> 00:00:35,080 creating programs that deal with date or time. 8 00:00:36,380 --> 00:00:40,350 There are two main methods that computers use to keep time. 9 00:00:40,350 --> 00:00:44,538 And you'll likely encounter both in your journey as a programmer depending on 10 00:00:44,538 --> 00:00:46,090 what you do. 11 00:00:46,090 --> 00:00:51,140 These are UTC time and the Unix timestamp. 12 00:00:51,140 --> 00:00:54,483 UTC stands for Coordinated Universal Time and 13 00:00:54,483 --> 00:00:58,520 it's basically the global standard for timekeeping. 14 00:00:59,880 --> 00:01:02,440 You may even know it as Greenwich Mean Time. 15 00:01:03,710 --> 00:01:06,920 Imagine it as the official time that everyone agrees on. 16 00:01:06,920 --> 00:01:14,920 You know how you've often seen your time zone written as GMT+9 or GMT- 7? 17 00:01:14,920 --> 00:01:20,960 Well, this is GMT+0, or GMT or simply UTC. 18 00:01:22,070 --> 00:01:26,527 It's often used as a reference point because it doesn't change with daylight 19 00:01:26,527 --> 00:01:27,750 saving or time zone. 20 00:01:29,230 --> 00:01:34,360 Programmers often default to UTC to avoid issues with time zones and 21 00:01:34,360 --> 00:01:38,100 UTC is used if you schedule cron jobs. 22 00:01:38,100 --> 00:01:42,341 Some other use cases are in aviation, weather forecasts, and 23 00:01:42,341 --> 00:01:45,230 even in the International Space Station. 24 00:01:46,970 --> 00:01:50,950 The Unix timestamp is a computer's way of telling time. 25 00:01:52,060 --> 00:01:56,823 Picture a starting point, called the Unix epoch, 26 00:01:56,823 --> 00:02:02,040 set on January 1, 1970, 00:00:00 UTC. 27 00:02:02,040 --> 00:02:09,300 A Unix timestamp is just the count of seconds that have passed since that epoch. 28 00:02:10,730 --> 00:02:14,621 This timestamp idea helps computers handle time consistently, 29 00:02:14,621 --> 00:02:16,890 no matter where they are in the world. 30 00:02:18,210 --> 00:02:23,713 So when you see a Unix timestamp like 1627892167 31 00:02:23,713 --> 00:02:28,993 it means that that's how many seconds have elapsed since 32 00:02:28,993 --> 00:02:33,850 that specific point in time, January 1 1970. 33 00:02:33,850 --> 00:02:38,144 Some use cases are storing timestamps in MySQL or 34 00:02:38,144 --> 00:02:42,438 PostgreSQL, file timestamps in Unix systems, 35 00:02:42,438 --> 00:02:47,464 timestamps in archive file formats like RAR and TAR, and 36 00:02:47,464 --> 00:02:52,820 Discord's own dynamic timestamp uses the Unix timestamp. 37 00:02:54,480 --> 00:02:59,421 Now, all this seems well and good, but it would be a little tricky to have 38 00:02:59,421 --> 00:03:02,664 to convert our thinking into Unix timestamps or 39 00:03:02,664 --> 00:03:06,690 UTC every time we worked with dates or times. 40 00:03:06,690 --> 00:03:10,044 And what if you just wanted to work with a time of day or 41 00:03:10,044 --> 00:03:12,580 a day without worrying about the time? 42 00:03:13,710 --> 00:03:18,580 Luckily, Python comes with a set of really solid tools for dealing with dates and 43 00:03:18,580 --> 00:03:19,090 times.