[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: "date" doesn't work

From: Bob Proulx
Subject: Re: "date" doesn't work
Date: Sat, 30 Aug 2003 22:40:26 -0600
User-agent: Mutt/1.4i

Karel Kulhavý wrote:
> I have used "date" according to supplied "info" documentations and figured
> out it doesn't work.

> Date: Wed, 25 Mar 2020 19:11:03 +0100

Oh yes, you do need to get 'date' working for you.  :-)

If you are on a network of computers and not just on an isolated
machine then I highly recommend using NTP to keep your time
corrected.  Usually that means running 'ntpdate' at boot time to jump
the time to the correct time and then starting up 'ntpd' to run to
keep the time corrected.  You will need a time server to sync from.
Usually DNS servers are compatible and have NTP running.  So that
would be a good place to guess.

> address@hidden:~$ date 08282152200300
> date: invalid date `08282152200300'

The synopsis for date shows.

     date [-u|--utc|--universal] [ MMDDhhmm[[CC]YY][.ss] ]

Therefore you need to put a '.' before your seconds since you are
including them in your setting.

  date 082821522003.00

But that is not really expected when the seconds are zero.  In the
classic form of the command you would just have the following.  And
that is why the docs say "consist entirely of digits".  The seconds
came later.

  date 082821522003

> I didn't find a set example in the info except for setting time 2
> minutes ahead.

Yes this has come up a couple of times recently.  There are lots of
examples from the new part of the command with the human type strings
of dates.  But no examples of the classic date command syntax.
Something to be fixed.

> man date says: "-s, --set=STRING set time described by STRING". I
> can't figure out what "described by STRING means". It isn't
> described anywhere else in 'man date'.

For that you will need to look in the 'info date' manual which is the
complete manual to the GNU date program.  The man page is meant as a
quick syntax reference.  But the info pages have all of the info.
Look in the 'Date input formats' section.  Here is an example using
your case.

  date --set='28 Aug 2003 21:52'

That is probably a little more readable than the original digits only
format.  Here are some other examples.  I am using --date since I
really don't want to change the date while testing.

  date --date='Sat Aug 30 22:36:39 MDT 2003'
  date --date='Sat, 30 Aug 2003 22:36:37 -0600'

This is not really useful by itself.  But adding or subtracting can
make it useful.

  date -R --date='Sat, 30 Aug 2003 22:36:37 -0600 + 2 weeks'
  Sat, 13 Sep 2003 22:36:37 -0600

Hope that helps,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]