I'm looking for a way to have the "date" command output the date in a specific format.
I'm not familiar with the different ways to use the date command at all. i read up on it, but i dont get how to manipulate it.
i know that i can get the date format to give me a format like:
2012-10-13
by typing:
$(date +%Y-%m-%d)
but i'm clueless on how to do the same for date formats like the below? how do i include the time? and timezone (where shown below)?
2012/02/21 16:23:13 UTC
[#|2012-02-21T17:17:39.495+0000
2012-02-21 16:34:43,897
[Tue Feb 21 04:02:27 2012]
Feb 21 14:00:53
Wed Mar 28 15:46:21 2012
<Mar 29, 2012 4:41:49 PM UTC>
2012.02.24 19:08:47
04/21/2012 05:00:21 PM
120806 23:44:48 (year,month,day)
10/9/12 11:06:43:131 PDT
notice how for the date "10/9/12", the day of the month is "single digit". some date formats have "2" digits for the day of the month, as in "09" instead of "9". how can the date format be used to output the formats as is shown in all of the above?
~/$ date +"%Y/%m/%d %H:%M:%S %Z"
2012/10/13 16:51:50 IST
~/$ date +"[#|%Y/%m/%dT%H:%M:%S %Z"
[#|2012/10/13T16:53:43 IST
~/$ date -u +"%Y/%m/%dT%H:%M:%S %Z"
2012/02/21 16:23:13 UTC
Adjusting for the others should be possible from the examples above and the man page, hope that helps.