Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Preview
Video Player
00:00
00:00
00:00
- 2x 2x
- 1.75x 1.75x
- 1.5x 1.5x
- 1.25x 1.25x
- 1.1x 1.1x
- 1x 1x
- 0.75x 0.75x
- 0.5x 0.5x
Discover how computers perceive time. Explore UTC time, the global standard, and the Unix timestamp, a computer's unique way of telling time. Get ready to dive into the fundamentals of time in the digital realm!
Resources
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
[MUSIC]
0:00
Hi, I'm Rachel,
a Python teacher here at Treehouse.
0:09
If you're a programmer,
you're going to have to deal with dates or
0:14
times eventually, and sometimes,
even at the same time.
0:17
Now, computers think about time a little
differently than we do as humans, so
0:22
it's our job as programmers to have
an understanding of that before we start
0:27
creating programs that deal with date or
time.
0:32
There are two main methods that
computers use to keep time.
0:36
And you'll likely encounter both in your
journey as a programmer depending on
0:40
what you do.
0:44
These are UTC time and the Unix timestamp.
0:46
UTC stands for
Coordinated Universal Time and
0:51
it's basically the global standard for
timekeeping.
0:54
You may even know it as
Greenwich Mean Time.
0:59
Imagine it as the official
time that everyone agrees on.
1:03
You know how you've often seen your
time zone written as GMT+9 or GMT- 7?
1:06
Well, this is GMT+0, or GMT or simply UTC.
1:14
It's often used as a reference point
because it doesn't change with daylight
1:22
saving or time zone.
1:26
Programmers often default to UTC to
avoid issues with time zones and
1:29
UTC is used if you schedule cron jobs.
1:34
Some other use cases are in aviation,
weather forecasts, and
1:38
even in the International Space Station.
1:42
The Unix timestamp is
a computer's way of telling time.
1:46
Picture a starting point,
called the Unix epoch,
1:52
set on January 1, 1970, 00:00:00 UTC.
1:56
A Unix timestamp is just the count of
seconds that have passed since that epoch.
2:02
This timestamp idea helps computers
handle time consistently,
2:10
no matter where they are in the world.
2:14
So when you see a Unix
timestamp like 1627892167
2:18
it means that that's how many
seconds have elapsed since
2:23
that specific point in time,
January 1 1970.
2:28
Some use cases are storing
timestamps in MySQL or
2:33
PostgreSQL, file timestamps
in Unix systems,
2:38
timestamps in archive file
formats like RAR and TAR, and
2:42
Discord's own dynamic timestamp
uses the Unix timestamp.
2:47
Now, all this seems well and good, but
it would be a little tricky to have
2:54
to convert our thinking
into Unix timestamps or
2:59
UTC every time we worked with dates or
times.
3:02
And what if you just wanted
to work with a time of day or
3:06
a day without worrying about the time?
3:10
Luckily, Python comes with a set of really
solid tools for dealing with dates and
3:13
times.
3:18
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up