Visit Our UNIX and Linux User Community


Change of System Date format


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Change of System Date format
# 1  
Old 02-09-2010
Change of System Date format

I have this T5220 server with Solaris 10 installed on to it. Now when I fire the command "date" the o/p I get is as follows :
Code:
 
bash-3.00# date
Tuesday, February  9, 2010  7:25:24 PM IST

whereas I want the date to appear in this format:
Code:
bash-3.00# date
Tue Feb  9 19:26:06 IST 2010

Can anyone suggest me changes to accomplish the same.

this is my system's enviorn and locale settings :
Code:
 
root@bgw # env
MANPATH=/opt/VRTSob/man:/opt/VRTS/man:/opt/VRTSvxvm/man::/usr/man:/usr/share/man:/opt/SUNWexplo/man:/opt/SUNWsneep/man:/opt/CTEact/man:/opt/SUNWsscs/man
HZ=100
LC_MONETARY=en_US.ISO8859-1
TERM=vt100
SHELL=/sbin/sh
LC_NUMERIC=en_US.ISO8859-1
LD_LIBRARY_PATH=/usr/openwin/lib
OPENWINHOME=/usr/openwin
PATH=/usr/sbin:/usr/bin:/usr/ccs/bin:/usr/openwin/bin:/usr/dt/bin:/usr/platform/SUNW,Sun-Fire-V890/sbin:/opt/sun/bin:/etc/vx/bin:/opt/VRTS/bin:/etc/vx/bin:/opt/VRTSob/bin:/opt/VRTSvlic/bin:/opt/SUNWexplo/bin:/opt/SUNWsneep/bin:/opt/CTEact/bin:/opt/rsc/bin
MAIL=/var/mail/root
LC_MESSAGES=C
LC_COLLATE=en_US.ISO8859-1
PWD=/usr/bin
EDITOR=vi
TZ=Asia/Calcutta
PS1=root@bgw # 
PS2=root@bgw > 
SHLVL=1
HOME=/
LOGNAME=root
LC_CTYPE=en_US.ISO8859-1
LC_TIME=en_US.ISO8859-1
_=/usr/bin/env
OLDPWD=/
 
root@bgw # locale
LANG=
LC_CTYPE=en_US.ISO8859-1
LC_NUMERIC=en_US.ISO8859-1
LC_TIME=en_US.ISO8859-1
LC_COLLATE=en_US.ISO8859-1
LC_MONETARY=en_US.ISO8859-1
LC_MESSAGES=C
LC_ALL=


Last edited by Scott; 02-09-2010 at 11:10 AM.. Reason: Please use code tags
# 2  
Old 02-09-2010
On my OpenSolaris 10 , locale is "C" .
and the date output is what you want .
# 3  
Old 02-16-2010
What is "system date format" in the application context? You should always use formatting when parsing/displaying the date.
Code:
date +%Y%M%D

Use "--help" to get list of the available format patterns. Avoid assumptions that the LANG has some predefined value as it is very error prone.
# 4  
Old 02-16-2010
The default date format is part of the locale -
Quote:
-- from the Solaris 9 man page for date:
The following is the default form for the "C" locale:

%a %b %e %T %Z %Y

For example,

Fri Dec 23 10:10:42 EST 1988
And, no, you do not necessarily need to use formatting every time you use the date command. If you need output which does not match the default for your current locale then you can either change your locale setting by redefining the LC_TIME environment variable or using formatting strings.

Something else is odd in the OP's envrironment. You can create custom envrionments
-- en_US.ISO8859-1 is standard AFAIK. So on an untweaked system:
Code:
worx> locale
LANG=
LC_CTYPE="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_COLLATE="C"
LC_MONETARY="C"
LC_MESSAGES=C
LC_ALL=C

worx> date
Tue Feb 16 13:54:13 MST 2010

worx> export LC_TIME=LC_TIME=en_US.ISO8859-1

worx> date
Tue Feb 16 13:54:24 MST 2010


worx> export LC_ALL=en_US.ISO8859-1
worx> locale
LANG=
LC_CTYPE=en_US.ISO8859-1
LC_NUMERIC=en_US.ISO8859-1
LC_TIME="en_US.ISO8859-1"
LC_COLLATE=en_US.ISO8859-1
LC_MONETARY=en_US.ISO8859-1
LC_MESSAGES="en_US.ISO8859-1"
LC_ALL=en_US.ISO8859-1

worx> date
Tue Feb 16 13:55:46 MST 2010

The locale defined for LC_TIME in en_US.ISO8859-1 does not vary from locale == C. At least on an out-of-the-box Solaris install. Somebody has customized that locale file on the OP's box. IMO.
This User Gave Thanks to jim mcnamara For This Post:

Previous Thread | Next Thread
Test Your Knowledge in Computers #618
Difficulty: Medium
Python is strongly object-oriented in the sense that everything is an object including numbers, strings and even functions.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Change just the date format

need some more help please i have a large file and i want to change just the date format with awk or sed from this yyyy-mm-dd 2016-04-15 8.30 2016-04-15 7.30 2016-04-13 7.30 2016-04-11 8.30 2016-04-11 7.30 2016-04-08 8.30 2016-04-08 7.30 2016-04-06... (5 Replies)
Discussion started by: bob123
5 Replies

2. UNIX for Dummies Questions & Answers

Change Date from one format to other

Hi I wish to change date from one format to another in unix. eg: INPUT DATE: 2013159 (YEAR & NUMBER OF DAY) OUTPUT DATE required: 20130608 (YYYYMMDD) how to do it ? Thanks in advance. (6 Replies)
Discussion started by: dashing201
6 Replies

3. Shell Programming and Scripting

Change the date format

Hi, I was looking for a script to change the date from one format to other. A search in the forum gave me the below script as a result. #! /bin/ksh format=YYYYMMDD YEAR=${format%????} DAY=${format#??????} MON=${format#$YEAR} MON=${MON%$DAY} echo $MON/$DAY/$YEAR I got it... (2 Replies)
Discussion started by: prithvirao17
2 Replies

4. Shell Programming and Scripting

Change the date format

Hi all, I have a file that every line starts with the date and time. The format is like YYYYMMDDHHMM and I woulk like to change it to MM/DD/YY<space>HH:MM. I tried to figure out a way to do it with sed, but I don't know how I could reorganize the digits of the first format. Does anyone have any... (1 Reply)
Discussion started by: geovas
1 Replies

5. Shell Programming and Scripting

Date format change

Dear Friends, Need your help once again, I have a variable ( e.g. ${i}) whoch has date in MM/DD/YYYY (E.g. 12/31/2011) format. I want to change it to DD/MM/YYYY (e.g. 31/12/2011) format. Request you to guide me as we are unable to do the same. Thanks in advance Anu. (1 Reply)
Discussion started by: anushree.a
1 Replies

6. Shell Programming and Scripting

How to change the date format

Hi Guys, Can someone help me on how to change the date format using sed or any unix command to give my desired output as shown below. INPUT FILE: 69372,200,20100122T17:56:02,2 53329,500,20100121T11:50:07,2 48865,100,20100114T16:08:16,2 11719,200,20100108T13:32:20,2 DESIRED... (2 Replies)
Discussion started by: pinpe
2 Replies

7. Shell Programming and Scripting

Date Format Change

Hi, Please can I have some command to get yesterday in YYMMDD format? This will be used in ksh Thanks, (2 Replies)
Discussion started by: smalya
2 Replies

8. Shell Programming and Scripting

Date Format Change

Hi I have a date format in a variable as Mon Jan 11 03:35:59 2010. how do i change it to YYYYMMDD format (3 Replies)
Discussion started by: keerthan
3 Replies

9. Shell Programming and Scripting

How to Change the Format of a Date

Hi All, this is my second post, last post reply was very helpful. I have a data that has date in DD/MM/YYYY (07/11/2008) format i want to replace the backslash by a dot(.) so that my awk script can read it inside the C shell script that i have written. i want to change 07/11/2008 to... (3 Replies)
Discussion started by: asirohi
3 Replies

10. UNIX for Dummies Questions & Answers

How to change it to the date format

Hi, I want to know how to change this string to date format 20061102122042 to 02-11-2006 12:20:42 or 02-Nov-2006 12:20:42 Please let me know at the earliest.Thanks in advance. Regards, Preetham R. (3 Replies)
Discussion started by: preethgideon
3 Replies

Featured Tech Videos