Page 1 of 1

How to I set the time and date?

Posted: Thu Jul 05, 2012 3:09 am
by shawnerz
All,
I feel really stupid asking a basic question, but I can't seem to set the time and date.
As I understand it, the pi has no realt time clock (RTC). Hence, there should be no /dev/rtc and the hwclock command should do nothing. Is this correct?

I am in the US. I edited /etc/timezone to America/New_York (and rebooted several times). When I type date, it still returns the time in the BST timezone. :(

I am not acting as a NTP server. Should I make any changes to ntp.conf? Is the pi already obtaining time from server X.debian.pool.ntp.org?
-Shawn

Re: How to I set the time and date?

Posted: Thu Jul 05, 2012 6:27 am
by SirLagz
dpkg-reconfigure tzdata

Re: How to I set the time and date?

Posted: Thu Jul 05, 2012 7:29 am
by penguintutor
The Raspberry Pi is already configured as an ntp client using the Debian ntp servers. As long as you have an Internet connection you should get the correct time.

If you don't have an Internet connection then you can use the date command to set the date / time appropriately.

eg.
sudo date -s "Jul 5 08:10"

The correct timezone for New York is
US/Eastern
This is what you should put in /etc/timezone

Or it's easier as per SirLagz comment using dpkg-reconfigure. That needs to be run as root - so using sudo:

sudo dpkg-reconfigure tzdata

Re: How to I set the time and date?

Posted: Thu Jul 05, 2012 7:36 am
by Jim JKla
If you use the wheezy image there's a timezone section in the raspi-config and there's stuff on the wiki on that.

Re: How to I set the time and date?

Posted: Fri Jul 06, 2012 1:30 am
by shawnerz
Penguintutor and SirLagz: thank you for the command. That worked. I really thought /etc/timezone would have been the place to do this, but I guess not.

Jim Jkla: I'm not using wheezy. I'm using debian "squeeze".

Re: How to I set the time and date?

Posted: Fri Jul 06, 2012 1:43 am
by SirLagz
No problems :)

Re: How to I set the time and date?

Posted: Sat Jul 14, 2012 4:20 am
by techsurvivor
Fix for the above you put in (for example if you're Eastern timezone in North America)

Code: Select all

America/Eastern
or Central

Code: Select all

America/Central

Re: How to I set the time and date?

Posted: Wed Dec 12, 2012 12:33 am
by groundup
For archlinux:
systemctl enable openntpd.service
echo "US/Eastern" > /etc/timezone
rm /etc/localtime
ln -s /usr/share/zoneinfo/US/Eastern /etc/localtime

Re: How to I set the time and date?

Posted: Tue May 19, 2015 2:29 pm
by jaywant
Same problem with me too, but i am trying to set the time zone as Kolkata, but its showing wrong date and time.
I tried the config..
Still not fixed... :(
Any solution???

Re: How to I set the time and date?

Posted: Tue Apr 26, 2016 9:00 pm
by GICSDNSA
I ran your command and its giving me that the time zone is correct as America/New_York. But its also telling me that the date is March 6th and is 22:31 hrs and yet today is April 26th and its only 17:00 hrs. Is the server that it looks at on the net incorrect?

Re: How to I set the time and date?

Posted: Tue Apr 26, 2016 10:26 pm
by DougieLawson
sudo date --set '2016-04-26 18:26:00'
should get you a bit closer.

Re: How to I set the time and date?

Posted: Wed Nov 09, 2016 12:18 pm
by esaofeccola
Hello all,

so, RasPi gets the time from NTP server.
I've had no success updating any of my RasPis time using Wifi. Not with Raspbian or, like, OpenELEC.
You always need wired eth0 connected.
I just wonder why is that?

Thank you,