[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How do I get datetime to stop showing seconds?

On 16Oct2020 22:07, Albert-Jan Roskam <sjeik_appie at> wrote:
>   I was using'T', 'seconds')
>   Not 100% sure, but the strings seemed to be 2hrs off. Could it be that
>   this Linux server was using the wrong time zone?

Maybe. This is why timezones are such a nightmare, and programmes 
working with datetime as their primary structure are fragile (hmm, is 
this _naive_ (untimezoned) datetime in local time? What _is_ local time? Was 
the naive datetime obtained correctly?  etc).

Hence the common recommendation to work in seconds since an epoch (on 
UNIX that epoch is midnight 01 January 1970 GMT). Then timezones are 
just when presenting to a human.

But also, on UNIX and UNIX-like (Linux) the timezone is an aspect of 
your environment; setting the $TZ environment various suitably will 
display times according to your preference.  The system default for when 
$TZ is not set is usually in the /etc/timezone file, but you can set $TZ 
for yourself and have your own localtimes generally displayed.

Cameron Simpson <cs at>