Skip to main content

cannot set date: Invalid argument

While playing around with GNU/date, this happened:

# date
Wed Jul 22 10:24:05 CEST 2009
# date --set='1970-01-01'
date: cannot set date: Invalid argument
Thu Jan  1 00:00:00 CET 1970
So, date gives an error but still modifies the system time? Let's have a closer look:
# strace -ff -F date --set='1970-01-01' 2>&1 | grep sett
clock_settime(CLOCK_REALTIME, {18446744073709548016, 0}) 
      = -1 EINVAL (Invalid argument)
settimeofday({18446744073709548016, 0}, NULL) 
      = -1 EINVAL (Invalid argument)
Wow, scary stuff. However, after a bit more thinking and searching we try again, a bit different this time:
# TZ=GMT date --set='1970-01-01'
Thu Jan  1 00:00:00 GMT 1970
# date
Thu Jan  1 01:00:04 CET 1970
Oh, and while we're at it: it looks like openSolaris comes with GNU/date as its default date(1) command now. It's three years old already (from GNU/coreutils 6.7), but at least we are a bit more flexible when it comes to displaying date & time.