Koliko je ura? Kako naši sistemi prikazujejo, izračunavajo, oblikujejo in sinhronizirajo datume in ure
That sounds like a simple question, but you’d be surprised at how complex the infrastructure provides you with an accurate time. When your users exist across time zones or even travel across time zones while using your systems, there’s an expectation that everything works seamlessly.
Ampak to ni preprosto.
Example: You have an employee in Phoenix who needs to schedule an email for 8:00 AM on Monday for his company in Los Angeles. Phoenix doesn’t adjust for daylight savings time; Los Angeles does. And what about the recipients? Should they receive the email at 8:00 AM on Monday in their respective time zone? Or will subscribers in New York receive their email at 11:00 AM EST on Monday?
Kako je čas prikazan na vašem računalniku
- Operacijski sistem (OS) – Vaš operacijski sistem poišče čas na svoji uri realnega časa (RTC). It adjusts the format of the date for your locale and the time for your appropriate time zone, typically determined by the location of your device.
- Oblike datumov – Obstaja več običajnih formatov datumov, vključno z:
- Datum gregorijanskega koledarja (LLLL-MM-DD), npr. 2022-02-08
- Datum v slogu Združenih držav (MM/DD/LLLL), npr. 02. 08. 2022
- Datum v evropskem slogu (DD/MM/LLLL), npr. 08. 02. 2022
- Časovni pasovi – There are 24 time zones in the world, each roughly 15 degrees of longitude apart from the other. Time zones divide the world into regions with the same standard time so that people in each time zone can have a common time for their daily activities.
- Poletni čas – V regijah, kjer upoštevajo poletni čas, se ure pomaknejo za eno uro naprej spomladi in za eno uro nazaj jeseni. Posledica tega je dodatna ura dnevne svetlobe zvečer v poletnih mesecih, pomeni pa tudi, da sonce vzide in zaide uro prej zjutraj oziroma zvečer v zimskih mesecih.
- Oblike datumov – Obstaja več običajnih formatov datumov, vključno z:
- Ura v realnem času (RTC) – your computer maintains the time, even when turned off, using a chip known as the RTC. When it’s not powered, a small lithium battery keeps the chip ticking (pun intended) and can power it for up to a decade without charge.
- Network Time Protocol (NTP) – ko imajo operacijski sistemi vzpostavljeno povezavo z internetom, uporabljajo NTP za sinhronizacijo svojih ur s skupino časovnih strežnikov, vključno s tistimi, ki jih zagotavlja Network Time Protocol. Privzeto se Windows sinhronizira s strežniki NTP enkrat na 7 dni, medtem ko se macOS sinhronizira enkrat na uro. NTP vzdržujejo svoj čas z uporabo usklajenega univerzalnega časa (UTC). When a client requests the current time from an NTP server, the server responds with a 64-bit value representing the number of seconds since January 1, 1900, at 00:00:00 UTC.
- Usklajeni univerzalni čas (UTC) – a standardized time used as the basis for all timekeeping in the world. It is based on the International Atomic Time (TAI), which measures the average time elapsed between two specific points in the orbits of Earth’s moon. UTC was first implemented in 1972 as a successor to TAI and Greenwich Mean Time (GMT). UTC se ohranja znotraj 0.9 sekunde časovne skale TAI, njegova natančnost pa se ohranja z uporabo atomskih ur in drugih tehnologij merjenja časa.
- Časovni pasovi 24 UTC so razdeljeni na odmik kategorije, kjer je vsak odmik prilagoditev za ustrezen čas v urah: UTC-12, UTC-11, UTC-10, UTC-9, UTC-8, UTC-7, UTC-6, UTC-5, UTC-4, UTC-3, UTC-2, UTC-1, UTC, UTC+1, UTC+2, UTC+3, UTC+4, UTC+5, UTC+6, UTC+7, UTC+8, UTC+9, UTC+10 in UTC+11.
- Mednarodni atomski čas (TAI) – časovni standard, ki temelji na povprečnem času, pretečenem med dvema določenima točkama v orbiti Zemljine lune. TAI je ena najbolj natančnih in stabilnih razpoložljivih časovnih lestvic, vzdržuje pa jo Mednarodni urad za uteži in mere.
- Atomske ure – so zelo natančni merilniki časa, ki za merjenje časa uporabljajo naravne vibracije atomov. Najpogostejša vrsta atomske ure je cezijeva atomska ura, ki za merjenje časa uporablja vibracije cezijevih atomov. Natančnost atomske ure ohranja stabilnost frekvence elektromagnetnega sevanja, ki ga oddajajo atomi cezija. Ta frekvenca je tako stabilna, da se skozi tisoče let spremeni le za delček sekunde. Frekvenco elektromagnetnega sevanja nato primerjamo s kvarčnim oscilatorjem, ki se uporablja za krmiljenje števca. Števec šteje število ciklov elektromagnetnega sevanja in to štetje se uporablja za izračun časa. Števec se nenehno popravlja, da se zagotovi, da ostane sinhroniziran z vibracijami cezijevih atomov.
Sodobni sistemi pogosto beležijo čase kot časovne žige Unix. Časovni žig Unix je številčna predstavitev določene točke v času, merjena kot število sekund, ki so pretekle od 1. januarja 1970 ob 00:00:00 UTC. Časovni žigi Unix se pogosto uporabljajo v računalniških sistemih, ker je z njimi enostavno delati in jih je mogoče preprosto primerjati, razvrščati in manipulirati. Prav tako so neodvisni od časovnih pasov, kar pomeni, da zagotavljajo standardizirano predstavitev časa, ki se lahko uporablja v različnih geografskih regijah.
Torej ... ko preverite čas, se prikaže
Delo z datumi v PHP
O tem, kako programsko prikažite leto za vašo izjavo o avtorskih pravicah da vam ga ne bo treba posodabljati vsako leto. Z datlji pa lahko naredite še ogromno več. Tukaj je nekaj primerov:
Prikaži datum kot 2023-02-08:
$current_date = date("Y-m-d");
echo $current_date;
Prikažite datum kot časovni žig 1612684800:
$timestamp = strtotime("2023-02-08");
echo $timestamp;
Prikažite datum in čas, oblikovan v UTC namesto lokalnega časovnega pasu kot 2023-02-08 15:25:00:
$utc_date = gmdate("Y-m-d H:i:s");
echo $utc_date;
Prikaži trenutni časovni žig Unix kot 1612742153:
$current_timestamp = time();
echo $current_timestamp;
Privzeto nastavite časovni pas na Los Angeles in nato prikažite datum in uro kot 2023-02-08 07:25:00:
date_default_timezone_set("America/Los_Angeles");
$date = date("Y-m-d H:i:s");
echo $date;
Organizing the PHP date format characters into logical groups, with each group in alphabetical order and the format characters as sub-bullets:
- Dan
d
– Day of the month, 2 digits with leading zeros (01 to 31). Example:15
D
– A textual representation of a day, three letters (Mon through Sun). Example:Thu
j
– Day of the month without leading zeros (1 to 31). Example:15
l
(lowercase ‘L’) – A full textual representation of the day of the week (Sunday through Saturday). Example:Thursday
S
– English ordinal suffix for the day of the month, 2 characters (st, nd, rd or th). Example:th
w
– Numeric representation of the day of the week (0 (for Sunday) through 6 (for Saturday)). Example:4
z
– The day of the year (starting from 0). Example for current date might not be accurate without exact calculations.
- mesec
F
– A full textual representation of a month (January through December). Example:February
m
– Numeric representation of a month, with leading zeros (01 to 12). Example:02
M
– A short textual representation of a month, three letters (Jan through Dec). Example:Feb
n
– Numeric representation of a month, without leading zeros (1 to 12). Example:2
t
– Number of days in the given month (28 through 31). Example:28
- teden
W
– ISO-8601 week number of year, weeks starting on Monday (Example: 42, the 42nd week in the year). Example for current date might not be accurate without exact calculations.
- Leto
o
– ISO-8601 week-numbering year. This has the same value as Y, except that if the ISO week number (W) belongs to the previous or next year, that year is used instead. Example:2024
Y
– A full numeric representation of a year, 4 digits. Example:2024
y
– A two-digit representation of a year. Example:24
- Časovni pas
T
– Timezone abbreviation. Example:EST
e
– Timezone identifier. Example:America/New_York
P
– Difference to Greenwich time (GMT) with a colon between hours and minutes. Example:-04:00
O
– Difference to Greenwich time (GMT) without colon between hours and minutes. Example:-0400
Z
– Timezone offset in seconds. The offset for timezones west of UTC is always negative, and for those east of UTC is always positive. Example:-14400 (for EST)
Every language has its functions to work with UTC, timestamps, display formats, time zones, and daylight savings time. If you’re developing a platform, you’ll want to pay a lot of attention to how you’re storing time-based data as well as how you’re formatting and displaying it. If you’re a business, you’re going to want to ensure your platforms can manage working across time zones, display the appropriate formats for your users, as well as manage daylight savings time adjustments.
Torej ... Koliko je ura?
My operating system is formatting the date and time as Mar 18, 2024, 10:47 PM. The time has been adjusted from a Unix Timestamp to my time zone, adjusted for Daylight Savings Time. That time has been synchronized in the last hour from MacOS with an NTP server that is in UTC and adjusted to keep within 0.9 seconds with TAI and the atomic clocks. All of this, of course, is an accurate time provided for my location with respect to the Earth, Moon, and Sun… adjusted for Daylight Savings Time.