The year 2021 is for me correct Year 9.
When I use:
sudo date --set="9-1-29 00:17:00.990"
I get
date: cannot set date: Invalid argument
Is there another way to set Year to 9?
Linux systems cannot have their system date set to a time before the UNIX epoch, which is 1 January 1970.
No. The date in Linux is set starting from 00:00:00 UTC on 1 January 1970
. You can't set the date before that time/day.
Based on your clarification in comments, it sounds like you are primarily interested in the presentation of time, rather than setting your clock to the year 9 AD in the calendar used by most of the world.
The time format used by the Linux kernel is not directly tied to the presentation of dates and times. Instead, it represents time as the number of seconds since the epoch. In the Gregorian calendar this is 1st January 1970.
If we were using your calendar representation, then the epoch would instead be 1st January in the year -42. Adding kernel time_t
values to this date would give you the appropriate dates in your calendar representation.
Many programs rely on routines in the standard C library to convert kernel time values to the common Gregorian calendar values. One possible way to change how these programs work is to use the LD_PRELOAD
environment variable to inject replacements for these routines that produce the desired output.
In fact, this is what the sdate
package in Ubuntu does, although admittedly for humorous purposes (e.g. displaying all dates after March 2020 as part of that month, when run in COVID-19 mode). Maybe you could adapt that code to suit the representation you want?
septemberfy
function. It might be enough to update it to subtract a constant from tm_year
.
Feb 11, 2021 at 13:36
date2
and echo back the date as it is now but manipulated so it shows 9 (ie. something where 2021 -/- 2012 shows 9) It would for all other things still use 2021 but you would see 9 in command line.