shawnerz
Posts: 13
Joined: Mon Jun 04, 2012 3:56 pm

How to I set the time and date?

Thu Jul 05, 2012 3:09 am

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

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia
Contact: Website

Re: How to I set the time and date?

Thu Jul 05, 2012 6:27 am

dpkg-reconfigure tzdata
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044

User avatar
penguintutor
Posts: 358
Joined: Tue May 08, 2012 9:11 am
Location: UK
Contact: Website

Re: How to I set the time and date?

Thu Jul 05, 2012 7:29 am

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

User avatar
Jim JKla
Posts: 2218
Joined: Sun Jan 29, 2012 11:15 pm
Location: Newcastle upon Tyne UK

Re: How to I set the time and date?

Thu Jul 05, 2012 7:36 am

If you use the wheezy image there's a timezone section in the raspi-config and there's stuff on the wiki on that.
Noob is not derogatory the noob is just the lower end of the noob--geek spectrum being a noob is just your first step towards being an uber-geek ;)

If you find a solution please post it in the wiki the forum dies too quick

shawnerz
Posts: 13
Joined: Mon Jun 04, 2012 3:56 pm

Re: How to I set the time and date?

Fri Jul 06, 2012 1:30 am

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".

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia
Contact: Website

Re: How to I set the time and date?

Fri Jul 06, 2012 1:43 am

No problems :)
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044

techsurvivor
Posts: 4
Joined: Fri Jul 13, 2012 12:00 am

Re: How to I set the time and date?

Sat Jul 14, 2012 4:20 am

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

groundup
Posts: 1
Joined: Wed Dec 12, 2012 12:29 am

Re: How to I set the time and date?

Wed Dec 12, 2012 12:33 am

For archlinux:
systemctl enable openntpd.service
echo "US/Eastern" > /etc/timezone
rm /etc/localtime
ln -s /usr/share/zoneinfo/US/Eastern /etc/localtime

jaywant
Posts: 2
Joined: Mon Oct 27, 2014 10:04 am

Re: How to I set the time and date?

Tue May 19, 2015 2:29 pm

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???

GICSDNSA
Posts: 2
Joined: Tue Apr 19, 2016 9:11 pm

Re: How to I set the time and date?

Tue Apr 26, 2016 9:00 pm

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?

User avatar
DougieLawson
Posts: 30142
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: How to I set the time and date?

Tue Apr 26, 2016 10:26 pm

sudo date --set '2016-04-26 18:26:00'
should get you a bit closer.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.

esaofeccola
Posts: 7
Joined: Wed Nov 09, 2016 12:07 pm

Re: How to I set the time and date?

Wed Nov 09, 2016 12:18 pm

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,

Return to “Beginners”

Who is online

Users browsing this forum: No registered users and 52 guests