Deprecated: Creation of dynamic property Timber\Site::$pingback is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Site.php on line 180

Deprecated: Creation of dynamic property Timber\User::$name is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/User.php on line 118

Deprecated: Creation of dynamic property Timber\Post::$has_disclaimer is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_edit_lock is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_edit_last is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$onesignal_meta_box_present is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$onesignal_send_notification is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$onesignal_modify_title_and_content is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$onesignal_notification_custom_heading is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$onesignal_notification_custom_content is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_focuskw is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_metadesc is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_linkdex is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_content_score is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_estimated-reading-time-minutes is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_wordproof_timestamp is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$tipologia is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_tipologia is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$attributi is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_attributi is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$in_evidenza_newsletter is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_in_evidenza_newsletter is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$inviato_in_newsletter is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_inviato_in_newsletter is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_primary_category is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_primary_blz_affiliation_attributes is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_primary_content_type is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_primary_attributes is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_primary_speciali is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_thumbnail_id is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$response_body is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$status is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$newsletter_subject is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_newsletter_subject is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$newsletter_summary is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_newsletter_summary is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_date_gmt is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$comment_status is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$ping_status is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_password is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_name is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$to_ping is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$pinged is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_modified is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_modified_gmt is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_content_filtered is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$guid is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$menu_order is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_mime_type is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$comment_count is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$filter is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71
Unix Time Stamp: cos'è e a che cosa serve | IlSoftware.it

Unix Time Stamp: cos'è e a che cosa serve

Cos'è lo Unix Time Stamp e perché è così importante per tutte le elaborazioni informatiche che prevedono l'effettuazione di calcoli su date e orari. Il suggestivo traguardo raggiunto a metà novembre 2023.

La misurazione del tempo che passa è essenziale in qualunque applicazione informatica. Tant’è vero che non soltanto si è dapprima sentito il bisogno di creare protocolli di sincronizzazione di data e ora come NTP (Network Time Protocol) ma questo stesso meccanismo è diventato ormai superato per le imprese di elevato profilo che necessitano di rilevare e registrare, con estrema accuratezza, l’orario corrente. Meta, ad esempio, ha sostituito NTP con PTP (Precision Time Protocol) per ottenere una sincronizzazione dell’orario approssimata, addirittura, al nanosecondo.

Abbiamo visto, inoltre, quanto le anomalie nella gestione di data e ora possano causare danni ingenti. Nel caso di Windows, ci siamo ad esempio soffermati sul caso emblematico della funzionalità Secure Time Seeding.

Unix Time Stamp: un approccio universale per misurare il tempo

Con l’espressione Unix Time Stamp, o tempo Unix, o Epoch Time, si fa riferimento a un metodo universalmente utilizzato per rappresentare il tempo, indipendentemente dalla zona oraria o dalla località geografica. Questa universalità è fondamentale quando si gestiscono dati su scala globale o quando è necessario confrontare e sincronizzare informazioni provenienti da diverse parti del mondo.

Unix Time Stamp si basa sul concetto della misurazione del numero di secondi trascorsi dal 1° gennaio 1970 00:00:00 UTC alla data e ora corrente. L’approccio è davvero semplice ed efficace consentendo l’accesso a una modalità uniforme per eseguire operazioni di data e ora sui sistemi informatici. Questa semplicità facilita la manipolazione del tempo in applicazioni software e consente di evitare complicazioni legate alle diverse convenzioni di data e ora.

Se vi siete chiesti perché, spesso, togliendo la batteria tampone di un dispositivo il sistema – per default – mostra come data e ora proprio la mezzanotte del 1° gennaio 1970. Quella data è proprio il punto di partenza per la rappresentazione del tempo nei sistemi Unix e in molti altri sistemi informatici.

Molti servizi Web, API e protocolli di comunicazione utilizzano lo Unix Time Stamp per rappresentare le informazioni temporali. Questa standardizzazione facilita lo scambio di dati temporali tra sistemi eterogenei. I calcoli inoltre, sono particolarmente agevoli, perché l’aggiunta o la sottrazione di intervalli temporali si riduce a una semplice operazione matematica.

Come calcolare lo Unix Time Stamp

Per determinare lo Unix Time per una data specifica, è possibile utilizzare strumenti o librerie di programmazione che gestiscono le operazioni di data e ora. Ad esempio, in molti linguaggi di programmazione, è possibile ottenere il tempo Unix ricorrendo a semplici funzioni di gestione del tempo. Il codice Python seguente permette ad esempio di ottenere lo Unix Time per la data e ora desiderata:

from datetime import datetime, timezone
# Definire la data e l'ora desiderate
data_ora_desiderate = datetime(2027, 1, 15, 8, 0, 0, tzinfo=timezone.utc)
unix_time = int(data_ora_desiderate.timestamp())
print("Unix Time calcolato:", unix_time)

È però possibile raggiungere lo stesso risultato con qualunque linguaggio di programmazione oppure servendosi di uno strumento online come questo servizio: basta digitare data e ora per ottenere il corrispondente Unix Time Stamp.

Se utilizzate un browser come Google Chrome, provate a visitare una qualunque pagina Web quindi a incollare quanto segue nella barra degli indirizzi:

var unixTimestamp = 1700000000;var data = new Date(unixTimestamp * 1000);var dataLocale = data.toLocaleString();alert("Unix Time: " + unixTimestamp + "\nData e ora locali: " + dataLocale);

Prima di premere il tasto Invio, aggiungete javascript: davanti al codice riportato, all’inizio del contenuto della barra degli indirizzi.

Unix Time Stamp JavaScript

Otterrete esattamente quanto riprodotto in figura. Nell’esempio, abbiamo chiesto di convertire lo Unix Time Stamp 1700000000 nel corrispondente orario locale. Ovviamente è possibile sostituire tale valore con qualunque altro di propria scelta.

Il 14 novembre 2023, si è raggiunto il “suggestivo” Unix Time 1700000000: sono trascorsi esattamente 1,7 miliardi di secondo dallo storico 1° gennaio 1970. Il prossimo Unix Time “di rilievo” è fissato per il 15 gennaio 2027 alle ore 9 italiane quando si raggiungerà un tempo Unix pari a 1800000000.

Epoch time rilevante

Per far capire quanto sia importante lo Unix Time, basti pensare che appena qualche anno fa è risultato necessario aggiornare il kernel Linux per scongiurare il bug dell’anno 2038. I programmi che utilizzano interi a 32 bit, infatti, possono gestire numeri compresi nell’intervallo tra -2147483648 e 2147483647 (232). Questo valore corrisponde proprio al 19 gennaio 2038, alle 4 e spicciole in Italia. È facile verificarlo con un servizio online o con il codice JavaScript presentato in precedenza. Ecco perché gli sviluppatori sono corsi ai ripari per scongiurare qualunque problema al raggiungimento della data e dell’ora indicati.

Ti consigliamo anche

Link copiato negli appunti