LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-11-2003, 12:19 AM   #1
Slycordinator
Member
 
Registered: Dec 2002
Location: Washington State
Posts: 30

Rep: Reputation: 15
All I want to do is change the date format...


Thought this would be easy.

Read through all the documentation on the "date" and nothing seems to work. I want to change it so the date indicates a 12-hour clock rather than 24-hour. I was able to have it change it's format for outputing by calling:

date +'%x %r %Z'

which outputted

12/10/03 10:01:29 PM PST

But after that, if I just called date I'd get:
Wed Dec 10 22:12:51 PST 2003

What's the use of having the date function just change the output format for a single-time use?
 
Old 12-11-2003, 12:31 AM   #2
Nis
Member
 
Registered: Jul 2003
Location: Virginia
Distribution: Ubuntu Hoary (5.04)
Posts: 550

Rep: Reputation: 31
All Linux commands are meant to run the same always if run without options. By running " date +'%x %r %Z' " you're passing options to date for that one time only. If you want date to return this every time you'll need to set up an alias. I suggest not calling it date but maybe 'now' or 'clock'. To setup an alias go to your home directory, open up .bashrc (notice the '.' before bashrc) in a text editor (vi, emacs, pico, gedit, etc.), and add this line to it:
alias clock="date +'%x %r %Z'"
Again, notice that the last little bit is ' (single quote) followed by " (double quote) which is kinda hard to show now that I look at it.
Save .bashrc, run 'source .bashrc' and the 'clock' command should output the date like that. Some other useful aliases are:
alias ll='ls -lh --color'
alias more='less' #'less' is a better pager than 'more'
 
Old 12-11-2003, 12:43 AM   #3
Slycordinator
Member
 
Registered: Dec 2002
Location: Washington State
Posts: 30

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by Nis
All Linux commands are meant to run the same always if run without options. By running " date +'%x %r %Z' " you're passing options to date for that one time only. If you want date to return this every time you'll need to set up an alias. I suggest not calling it date but maybe 'now' or 'clock'. To setup an alias go to your home directory, open up .bashrc (notice the '.' before bashrc) in a text editor (vi, emacs, pico, gedit, etc.), and add this line to it:
alias clock="date +'%x %r %Z'"
Again, notice that the last little bit is ' (single quote) followed by " (double quote) which is kinda hard to show now that I look at it.
Save .bashrc, run 'source .bashrc' and the 'clock' command should output the date like that. Some other useful aliases are:
alias ll='ls -lh --color'
alias more='less' #'less' is a better pager than 'more'
I don't see a file called .bashrc in my home directory.

/home/*** (*** represents my user name) contains no file of that name.

Not sure what to do.
 
Old 12-11-2003, 12:44 AM   #4
DrOzz
Senior Member
 
Registered: May 2003
Location: Sydney, Nova Scotia, Canada
Distribution: slackware
Posts: 4,185

Rep: Reputation: 60
make that file then :-)
 
Old 12-11-2003, 01:22 AM   #5
Slycordinator
Member
 
Registered: Dec 2002
Location: Washington State
Posts: 30

Original Poster
Rep: Reputation: 15
The main reason I'm trying to do this is the clock displayed all the time in my wm (I'm using Icewm btw) is displaying the time like so:
23:21:24
And I want it to say 11:20 PM.

I don't think creating this new clock alias will do anything with respect to this.
 
Old 12-11-2003, 01:27 AM   #6
Nis
Member
 
Registered: Jul 2003
Location: Virginia
Distribution: Ubuntu Hoary (5.04)
Posts: 550

Rep: Reputation: 31
Oh, I see. The way IceWM displays the time is controlled by its preferences file. The IceWM site has some good stuff about how to edit this file and I remember that one of the preferences is to control the output of the clock. Try checking the IceWM FAQ for more detailed instructions.
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
'date' command format Neorio Linux - General 3 01-18-2011 05:18 AM
Thunderbird Date Format dotancohen Linux - Software 9 10-15-2005 02:55 PM
Need workaround for Date Format Cyberdyne Slackware 2 07-22-2005 04:36 AM
A question regarding the date format marsques Linux - General 1 03-12-2005 05:28 PM
Date format Mik LQ Suggestions & Feedback 8 12-05-2004 10:14 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:24 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration