Date format-says April 2, I want it to say 02 April in BASH

No matter what I attempt, while using the man file for the date command— nothing I do seems to work.

What I want is the format for my date to be
%a %d %b %Y %R %S

i execute a sudo su -so as not to run into permissions problems, and I’ve tried the various options/flags for the date command to make my format stick permanently, and nothing works.

Even when I input:
date -sf +’%a %d %b %Y %R %S’

It outputs exactly what I want to see, but when I then execute
$ date
… it’s still the same crappy time format that I’m trying to change.

Any help is appreciated as I’m attempting to move over to Garuda from mint

There is no way to permanently change the date format (to my knowledge). It's a command line tool built to be minimal, not a date and time center with weather and whatnot.

If you want to automatically set a specific format when you use it, just alias it via alias date='date +"%a %d %b %Y %R %S"'

Just removed the -sf option because they seemingly serve no purpose here

3 Likes

At the start of your script (but after the shebang #!), set this environment variable, and date will use that localization. (So will everything else that uses localization.)

LC_ALL=de_DE.utf8
1 Like

This sounds like an xy problem. What are you trying to use date for?

1 Like

All fine here without alias :slight_smile:

image

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.