Sponsored Content
Full Discussion: Change of System Date format
Top Forums UNIX for Advanced & Expert Users Change of System Date format Post 302395682 by jim mcnamara on Tuesday 16th of February 2010 04:04:04 PM
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:
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
locale(1)						      General Commands Manual							 locale(1)

NAME
locale - Displays information about locales SYNOPSIS
locale [-a | -m] locale [-c] [-k] name... STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: locale: XCU5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. OPTIONS
Writes information about all available public locales. Writes the names of the specified locale categories. Writes the names and values of specified locale keywords. Writes the names of all character map (charmap) files that are available for specification to the -f option of the localedef command. OPERANDS
Specifies one or more of the following: A locale category, such as LC_TIME A keyword, such as am_pm in a locale category The reserved word charmap, which requests the name of the character map file used to produce the current locale Different types of names can be intermixed in any order. However, if a single name represents both a locale category name and a key- word name in the current locale, results are undefined. DESCRIPTION
The locale command without any options or arguments writes to standard output the names and values of all the current locale environment variables, such as LANG and LC_COLLATE. The locale command with the -a or -m options displays information about available locales and character maps on your system. If the -a option is specified, locale writes the names of all available public locales. These are locales that are available to any application. If the -m option is specified, locale writes a list of the names of all available character-mapping files. These values are suitable variable values for the -f option with the localedef command. The locale command with the name operand displays information about locale categories and keywords in the current locale. For example, the command could display information about the decimal_point keyword in the LC_NUMERIC category or information about all keywords in the LC_NUMERIC category. The name operand can be either a locale category, a keyword from a category, or the keyword charmap. The following table shows how the -c and -k options determine the level of information displayed by the locale command with respect to locale keywords: Options Set Information Written to Standard Output None Value of keyword specified by the name operand or values of all keywords in the category specified by the name operand. -c Name of category containing the keyword specified by the name operand or the name of the category specified by the name operand, followed by values of locale keywords. -k Names and values of locale keywords. -ck Name of category, followed by names and values of locale keywords. Following are the locale categories and the locale keywords that you can use in the name operand. Note that there are no keywords that you can specify in the locale command for the LC_COLLATE and LC_CTYPE categories; the XCU specification allows vendors to determine whether the locale command displays values for keywords in these two categories. Locale Category Locale Keywords LC_COLLATE None. LC_CTYPE None. CHARMAP charmap code_set_name mb_cur_max mb_cur_min LC_MESSAGES yesexpr noexpr yesstr nostr LC_MONETARY int_curr_symbol currency_symbol mon_decimal_point mon_grouping mon_thousands_sep positive_sign negative_sign int_frac_digits frac_digits p_cs_precedes p_sep_by_space n_cs_precedes n_sep_by_space p_sign_posn n_sign_posn debit_sign credit_sign left_parenthesis right_parenthesis LC_NUMERIC decimal_point thousands_sep grouping LC_TIME abday abmon alt_digits am_pm d_fmt d_t_fmt day era era_d_fmt era_d_t_fmt era_t_fmt era_year mon t_fmt t_fmt_ampm EXIT STATUS
Success. An error occurred. ERRORS
[Tru64 UNIX] To review locale diagnostic messages, enter the following command: % dspcat /usr/lib/nls/msg/en_US.ISO8859-1/locale.cat | more EXAMPLES
Assume that the LANG environment variable is set to fr_FR.ISO8859-1 and the LC_MONETARY environment variable to fr_CA.ISO8859-1. The fol- lowing example shows the results when you enter the locale command without options: % locale LANG=fr_FR.ISO8859-1 LC_COL- LATE="fr_FR.ISO8859-1" LC_CTYPE="fr_FR.ISO8859-1" LC_MONETARY="fr_CA.ISO8859-1" LC_NUMERIC="fr_FR.ISO8859-1" LC_TIME="fr_FR.ISO8859-1" LC_MESSAGES="fr_FR.ISO8859-1" LC_ALL= The LC_ALL variable, if set, overrides the values of other variables. For example, if LC_ALL is set to en_US.ISO8859-1, the setting implies LC_COLLATE=en_US.ISO8859-1, even if the LC_COLLATE environment variable is set to another locale. The following commands show two ways to retrieve the value of the decimal_point delimiter for the current locale: % locale -ck decimal_point LC_NUMERIC decimal_point="." % locale decimal_point . In the following example, the locale command retrieves any keywords defined in the CHARMAP, LC_CTYPE, and LC_COLLATE categories of the POSIX (C) locale: % locale -ck CHARMAP LC_CTYPE LC_COLLATE CHARMAP charmap="ISO8859-1" code_set_name="ISO8859-1" mb_cur_max=1 mb_cur_min=1 LC_COLLATE LC_CTYPE alnum=0x0002 alpha=0x0001 blank=0x0004 cntrl=0x0008 digit=0x0010 graph=0x0020 lower=0x0040 print=0x0080 punct=0x0100 space=0x0200 upper=0x0400 xdigit=0x0800 The following example shows a possible application of the locale and printf commands in a script to determine whether a user response is affirma- tive: if printf "%s " "$response" | grep -Eq "'locale yesexpr'" then <insert processing for affirmative response> else <insert processing for response other than affirmative> fi ENVIRONMENT VARIABLES
The following environment variables affect the behavior of the locale command: Provides a default value for the locale category variables that are not set or null. If set, overrides the values of all locale variables, including LANG. Determines the locale for the interpreta- tion of byte sequences as characters (single-byte or multibyte) in input operands and files. Determines the locale used to find the mes- sage catalog for diagnostic messages and other text displayed by the command. Determines the location of message catalogs for processing of LC_MESSAGES. SEE ALSO
Commands: localedef(1), printf(1) Functions: setlocale(3) Files: locale(4) Others: i18n_intro(5), l10n_intro(5), standards(5) Writing Software for the International Market locale(1)
All times are GMT -4. The time now is 01:21 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy