Setting Date and Time

From Openmoko

(Difference between revisions)
Jump to: navigation, search
(We already have a link to a more complete Timezone page up top. This is redundant.)
Line 31: Line 31:
  
 
  hwclock --systohc
 
  hwclock --systohc
 
== Local Time ==
 
 
If you want to have localtime setup, then link your proper zone file to /etc/localtime, similar to the following:
 
 
ln -s /usr/share/zoneinfo/America/New_York /etc/localtime
 
 
And restart the xserver so that your clock shows the right time:
 
 
/etc/init.d/xserver-nodm restart
 
  
 
== Future Work ==
 
== Future Work ==

Revision as of 17:35, 20 July 2008

Linux systems (such as the Freerunner) prefer that the system clock be set to universal time (UTC). Then, you will need to configure the timezone to display the time adjusted to local time.

See Timezone for instructions on changing the time zone.

For more information on Linux timekeeping, see Linux, Clocks, and Time. (But ignore mentions of /etc/sysconfig/clock. That doesn't apply to the Openmoko environment.)

Contents

Setting the date/time using "date"

To change the date on your Freerunner, issue one of the following commands:

date -s MMDDhhmm
date -s MMDDhhmmYYYY
date -s MMDDhhmmYYYY.ss

where MM is the month, 01-12; DD is the day, 01-31; hhmm is the time, 0000-2359; YYYY is the optional year, and .ss is the optional seconds.

Setting date/time from your linux box

 ssh root@openmoko "date -s `date --utc +%m%d%H%M%Y.%S`"

Setting the date/time automatically with NTP

If your Freerunner is connected to the internet, you can instead set the time automatically:

 opkg install ntpclient
 ntpclient -s -h pool.ntp.org

Syncing the hardware clock

No matter which method you used above, sync the hardware clock with the system time to make your change persist over reboots:

hwclock --systohc

Future Work

Presumably it might also be possible to use gpspipe (or something else) to set the date once you have a gps fix? In addition, the phone stack should set the date, time, and timezone once connected to a network.

Personal tools

Linux systems (such as the Freerunner) prefer that the system clock be set to universal time (UTC). Then, you will need to configure the timezone to display the time adjusted to local time.

See Timezone for instructions on changing the time zone.

For more information on Linux timekeeping, see Linux, Clocks, and Time. (But ignore mentions of /etc/sysconfig/clock. That doesn't apply to the Openmoko environment.)

Setting the date/time using "date"

To change the date on your Freerunner, issue one of the following commands:

date -s MMDDhhmm
date -s MMDDhhmmYYYY
date -s MMDDhhmmYYYY.ss

where MM is the month, 01-12; DD is the day, 01-31; hhmm is the time, 0000-2359; YYYY is the optional year, and .ss is the optional seconds.

Setting date/time from your linux box

 ssh root@openmoko "date -s `date --utc +%m%d%H%M%Y.%S`"

Setting the date/time automatically with NTP

If your Freerunner is connected to the internet, you can instead set the time automatically:

 opkg install ntpclient
 ntpclient -s -h pool.ntp.org

Syncing the hardware clock

No matter which method you used above, sync the hardware clock with the system time to make your change persist over reboots:

hwclock --systohc

Local Time

If you want to have localtime setup, then link your proper zone file to /etc/localtime, similar to the following:

ln -s /usr/share/zoneinfo/America/New_York /etc/localtime

And restart the xserver so that your clock shows the right time:

/etc/init.d/xserver-nodm restart

Future Work

Presumably it might also be possible to use gpspipe (or something else) to set the date once you have a gps fix? In addition, the phone stack should set the date, time, and timezone once connected to a network.