The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Formatting Date Variable (Pls help) gmoth Shell Programming and Scripting 1 02-19-2008 12:03 PM
formatting date for different locales Aeon UNIX for Dummies Questions & Answers 2 08-23-2007 01:39 AM
Date formatting knc9233 UNIX for Dummies Questions & Answers 8 01-16-2007 06:17 PM
date formatting mgirinath Shell Programming and Scripting 4 07-08-2006 06:08 AM
Formatting date radhika03 Shell Programming and Scripting 2 12-14-2005 02:56 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-09-2008
cesarNZ cesarNZ is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 70
formatting date in ksh

hi all,
in ksh, how do i format date so it includes hour and minute ?? i am trying the following command :

date +%Om/%Od/%Oy%OH:%M

but it displays the hour and minute concatenated with the day/month/year e.g 12/10/0814:08

when i want the output to be

12/10/08 14:08

i tried `date +%Om/%Od/%Oy %OH:%M` but that just leaves the time portion out and displays date only i.e 12/10/08.


thanks in advance.
  #2 (permalink)  
Old 12-09-2008
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is online now Forum Staff  
Moderator(The Tutor)
  
 

Join Date: Jun 2008
Location: INDIA
Posts: 1,419
simple !!
put a space inbetween year and hour

Code:
date +"%Om/%Od/%Oy %OH:%M"

  #3 (permalink)  
Old 12-09-2008
cesarNZ cesarNZ is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 70
nope that doesnt work as i tried that already as per my original post. However the below works :


date '+%m/%d/%y %H:%M:%S'


output :

12/10/08 14:23:53
  #4 (permalink)  
Old 12-09-2008
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is online now Forum Staff  
Moderator(The Tutor)
  
 

Join Date: Jun 2008
Location: INDIA
Posts: 1,419
Quote:
Originally Posted by cesarNZ View Post
nope that doesnt work as i tried that already as per my original post. However the below works :


date '+%m/%d/%y %H:%M:%S'


output :

12/10/08 14:23:53
oh common it will work i can bet on that.. you might have typed it wrong somewhere and your desired output can be possible by simply

Code:
 
home> date +"%D %T"
12/10/08 06:58:45
home> date +"%Om/%Od/%Oy %OH:%M"
12/10/08 06:59


Last edited by vidyadhar85; 12-09-2008 at 09:40 PM..
  #5 (permalink)  
Old 12-09-2008
fpmurphy's Avatar
fpmurphy fpmurphy is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2003
Location: Florida
Posts: 1,945
Which date are you using? Modern versions of ksh have a builtin date which has slightly different semantics than the standalone date utility. Try date --man. If it displays information, then you are using the builtin date.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:41 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0