[Techtalk] Simple date question

Miriam English mim at miriam-english.org
Mon Oct 7 09:43:43 UTC 2013


I think that the date command's option for timezone is just for 
displaying a date in a particular way. For example if you have a date as 
just a big number of seconds (e.g. 1381128099) then you can use this:

date +"%a  %Y-%m-%d %T %z"

to display something like this:

Mon  2013-10-07 19:29:20 +1000

(I'm in QLD, Australia, which is 10 hours ahead of GMT.)

Without the "%z" it just displays:

Mon  2013-10-07 19:29:20

Note how it isn't doing any conversions; it just displays the timezone 
information it finds already set on your machine.

To set your timezone depends upon what distribution of Linux you're 
using. I'm using mostly Puppy Linux so it is set when you install it, 
though you can change it from the main menu:

Menu > Desktop > Country Settings > Set Timezone

But this will be different for you if you're not using Puppy.
Have a look at whatever method your distribution has for changing your 
system settings.

Best wishes,

	- Miriam


mgmonza at sdf.lonestar.org wrote:
> Hi, all,
>
> This has been a typical linux time sponge for me.  I've been trying for
> far too many hours, reading man pages, duckduckgo'ing, etc, to simply
> set the time zone using the date command.
>
> Does anyone know that this CAN'T be done?  It would save me much time to
> know this too, but that most inscrutable of man pages seems to say it can.
>
>> From the DATE man page:
>   %Z     alphabetic time zone abbreviation (e.g., EDT)
>   %z     +hhmm numeric timezone (e.g., -0400)
>
> This was typical of the hundreds of trys I've done, and it did't work:
>
> sudo date -s +%Z --EDT
>
> All I'm interested is setting this via the command line, either with
> date or some other one-liner that can be put into my .bashrc. My main
> laptop died a month ago and all I've got now is my old XP laptop filled
> to the max with work stuff I'll need if I ever find a computer job
> again. There's no room for even the barest of Linuxes, so I've been
> using a live Ubuntu CD and copying over the minimum necessary to just
> use it as a linux box. Most of my aliases take care of making a storage
> unit look like my lost home, but time thing got me.
>
> This is my time alias, necessary because the disk sets the wrong time:
>
> alias settime="sudo date '+%l:%M %p' -s \$1"
>
> and works like this:
>
> settime 3:41am
>
> I'd just like that last tweak that sets it to EDT.
>
> Thanks!
>
> MG
> _______________________________________________
> Techtalk mailing list
> Techtalk at linuxchix.org
> http://mailman.linuxchix.org/mailman/listinfo/techtalk
>
>

-- 
If you don't have any failures then you're not trying hard enough.
  - Dr. Charles Elachi, director of NASA's Jet Propulsion Laboratory
-----
Website: http://miriam-english.org
Blogs:   http://miriam-e.dreamwidth.org
          http://miriam-e.livejournal.com




More information about the Techtalk mailing list