Posts

Showing posts with the label datetime

Writing a GenericEncoder to prevent JSON conversion errors

class GenericEncoder ( json.JSONEncoder ): import numpy def default ( self , obj ) : if isinstance (obj, numpy.generic): return numpy.asscalar(obj) elif isinstance (obj, datetime.datetime): return obj.strftime( '%Y-%m-%d %H:%M:%S' ) else : return json.JSONEncoder.default( self , obj)

Set time on Raspberry Pi

sudo timedatectl set-time '2018-10-02 09:53' date -s "2 OCT 2006 18:00:00" timedatectl set-time 04:00:00 sudo timedatectl set-time 04:00:00  sudo timedatectl set-ntp false  sudo timedatectl set-time 04:00:00  sudo timedatectl timedatectl set-ntp yes  yum install ntp ntpdate # systemctl start ntpd # systemctl enable ntpd # systemctl status ntpd # ntpdate -u -s 0.centos.pool.ntp.org 1.centos.pool.ntp.org 2.centos.pool.ntp.org Next, restart the ntpd daemon to synchronize CentOS NTP server date and time with your local date and time. # systemctl restart ntpd Now check using the timedatectl command if NTP synchronization is enabled and if it is actually synchronized. # timedatectl Lastly, using the hwclock utility, set the hardware clock to the current system time using the -w flag as follows. # hwclock  -w timedatectl list-timezones tzselect You can make this change permanent for yourse...