Autosave: 2024-04-28 17:50:04
This commit is contained in:
parent
24cf63dcec
commit
e6c654c913
2 changed files with 44 additions and 1 deletions
BIN
.zk/notebook.db
BIN
.zk/notebook.db
Binary file not shown.
|
@ -5,7 +5,7 @@ tags: []
|
||||||
created: Sunday, April 28, 2024
|
created: Sunday, April 28, 2024
|
||||||
---
|
---
|
||||||
|
|
||||||
# Time_and_computers
|
# Time and computers
|
||||||
|
|
||||||
## Epochs and Unix Time
|
## Epochs and Unix Time
|
||||||
|
|
||||||
|
@ -25,3 +25,46 @@ The deduction is as follows:
|
||||||
|
|
||||||
We are multiplpying the number of seconds in a minute by the number of minutes
|
We are multiplpying the number of seconds in a minute by the number of minutes
|
||||||
in an hour by the number of hours in a day.
|
in an hour by the number of hours in a day.
|
||||||
|
|
||||||
|
To represent times and dates before 1970, we use negative integers.
|
||||||
|
|
||||||
|
## UTC and time zones
|
||||||
|
|
||||||
|
"Coordinated Universal Time" (UTC) is the time standard against which the
|
||||||
|
world's timekeeping is synchronized. It is not itself a timezone, it is a
|
||||||
|
transcendent standard that defines what time zones are.
|
||||||
|
|
||||||
|
Time zones are defined relative to UTC, by their offset to this value.
|
||||||
|
|
||||||
|
For example North America is behind UTC by five or six hours hence uses the
|
||||||
|
notation UTC-5:00 or UTC-6:00.
|
||||||
|
|
||||||
|
UTC is the successor to GMT of which there were variances necessitating a
|
||||||
|
universal value. Despite this GMT is equal to UTC+00:00 so apart from when
|
||||||
|
daylight saving is in effect in the UK, GMT = UTC.
|
||||||
|
|
||||||
|
Depending on your locale, relative to UTC, you will get different outputs when
|
||||||
|
you attempt to log Unix Time.
|
||||||
|
|
||||||
|
Also daylight savings can impact on the outputs. For instance for half of the
|
||||||
|
year, when DST applies, the UK is UTC+01:00.
|
||||||
|
|
||||||
|
## Examples in Python
|
||||||
|
|
||||||
|
The following gives us the unix seconds in my current time zone (GMT DST):
|
||||||
|
|
||||||
|
```py
|
||||||
|
import time
|
||||||
|
print(time.time())
|
||||||
|
# 1714322393.2929392
|
||||||
|
```
|
||||||
|
|
||||||
|
If I want UTC, I can do:
|
||||||
|
|
||||||
|
```py
|
||||||
|
import datetime
|
||||||
|
print(datetime.datetime.utcnow().strftime('%s'))
|
||||||
|
# '1714318952'
|
||||||
|
```
|
||||||
|
|
||||||
|
We see clearly that they are not identical.
|
||||||
|
|
Loading…
Add table
Reference in a new issue