Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple question, Change the date format

Status
Not open for further replies.

adaaje

Technical User
May 26, 2006
60
AU
Hi guys,

I would like to change the date format from :
Fri Jun 16 18:14:32 2006

into :
20060616

I know to grab "2006" and '16', but what about to change Jun into 06, I'm sure you guys have quick idea to change this.

Thanks in advance guys,
 
You wanted this ?
date '+%Y%m%d'

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
man date

usual options are

%a locale's abbreviated weekday name (Sun..Sat)

%A locale's full weekday name, variable length (Sunday..Saturday)

%b locale's abbreviated month name (Jan..Dec)

%B locale's full month name, variable length (January..December)

%c locale's date and time (Sat Nov 04 12:02:33 EST 1989)

%C century (year divided by 100 and truncated to an integer)
[00-99]

%d day of month (01..31)

%D date (mm/dd/yy)

%e day of month, blank padded ( 1..31)

%F same as %Y-%m-%d

%g the 2-digit year corresponding to the %V week number

%G the 4-digit year corresponding to the %V week number

%h same as %b

%H hour (00..23)

%I hour (01..12)

%j day of year (001..366)

%k hour ( 0..23)

%l hour ( 1..12)

%m month (01..12)

%M minute (00..59)

you may have more on your version of *nix

Mike

"A foolproof method for sculpting an elephant: first, get a huge block of marble, then you chip away everything that doesn't look like an elephant."

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top