I have used the above date format to get the format but
when I try to issue the date command again, it's using
the default setting again.
Can you advise me how to make use of alias to add in the date format in the .login and .profile.
You cant make a permenant change to the date format, but you create an alias e.g.
alias mydate date +%d/%m/%y
now if you type mydate you will always get the format as above. To retain this, you need to add the alias line to your .profile or .login or .cshrc then when you login it will be set again.
I'm not sure if it's possible to change the date format permanently or not, though no doubt someone here will know whether it is. I think the basic difficulty lies in the Solaris date including a time element. Bearing in mind that cron and other scheduled tasks depend on the date and time, I wonder whether it's worth tinkering with it with the possibility that something might go kaput as a result. Just a thought.
Default date format (and others), are setting in locale environment, you can verify this with "locale":
# locale
LANG=C
LC_CTYPE="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_COLLATE="C"
LC_MONETARY="C"
LC_MESSAGES="C"
LC_ALL=
the LC_TIME environment var controls most default's of date/time commands, you can check default date format with:
# locale d_t_fmt
%a %b %d %H:%M:%S %Z %Y
you can check that is true by doing some checks:
# date
Thu Sep 06 00:59:10 WEST 2001
date +"%a %b %d %H:%M:%S %Z %Y"
Thu Sep 06 01:00:48 WEST 2001
you can also verify all defaults for LC_TIME with "locale LC_TIME", and all defaults with "locale LC_ALL"
so if you want to change default format of date you can change the value of LC_TIME to a locale that holds your required format,i.e, you can check if POSIX holds the default value you want by:
# LC_ALL=POSIX locale -ck d_t_fmt
LC_TIME
d_t_fmt="%a %b %d %H:%M:%S %Y"
if none of present locales will handle your format you can always build a locale for you with all the formats you want, solaris provide a source file of locale:
"/usr/lib/localedef/src/iso_8859_1" that you can change to build your own locale, change it and just compile it with "localedef",i.e, if you locale is "mylocale":
# cd /usr/lib/localedef/src
# mkdir mylocale
# cp iso_8859_1/* ./mylocale
# cd mylocale
... change files ...and compile ..
# localedef -v -i localedef.src -f charmap.src -x extension.src mylocale
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.