Skip to content
Advertisement

Date: Invalid Date Linux/Raspberry pi os [closed]

I know this is a fairly common question, but the answers I’ve seen before have not worked for me.

I’m simply trying to set the date. This was working a few months ago, and for some reason not anymore.

The command I’m using is :

sudo date -s “2021_03_09 10:36:41”

I’ve tried many variations, such as

sudo date +%Y_%m_%d_%H_%M_%S -s “2021_03_09_10_36_41”

and I always get

date: invalid date ‘2021_03_09 10:36:41’

I’ve also tried adding a time zone. Why would this happen all of a sudden?

Advertisement

Answer

Use dashes instead of the underscores.

sudo date -s '2021-03-09 10:36:41'
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement