<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Admin&#039;s Choice &#187; Basics</title>
	<atom:link href="http://adminschoice.com/tag/basics-of-unix/feed" rel="self" type="application/rss+xml" />
	<link>http://adminschoice.com</link>
	<description>Unix adminstrators documents , tip and more</description>
	<lastBuildDate>Thu, 11 Feb 2010 02:53:34 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Unix Date Format Examples</title>
		<link>http://adminschoice.com/unix-date-format-examples</link>
		<comments>http://adminschoice.com/unix-date-format-examples#comments</comments>
		<pubDate>Thu, 11 Feb 2010 02:53:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Basics]]></category>
		<category><![CDATA[Unix Date Format Examples]]></category>

		<guid isPermaLink="false">http://adminschoice.com/?p=417</guid>
		<description><![CDATA[Unix date format is needed  in the scripts, timestamped log files and  script generated reports .  This article attempts to simply date formatting with several examples .  Date command in Unix is used to format date as well as time . First portion of this article covers Date  function and the second portion has the  [...]]]></description>
			<content:encoded><![CDATA[<p>Unix date format is needed  in the scripts, timestamped log files and  script generated reports .  This article attempts to simply date formatting with several examples .  Date command in Unix is used to format date as well as time . First portion of this article covers Date  function and the second portion has the  time function covered .</p>
<p><strong>Unix   Basic date format</strong></p>
<p>$date &#8220;+&lt;Parameter&gt;&lt;seprator&gt;&lt;Parameter&gt;&lt;seprator&gt;&lt;Parameter&gt;</p>
<p>Where Parameters  is  any one or more Parameter from the list below and separator is a any field separator like  hyphen( &#8211; ) , slash \ , colon :   and it is optional.</p>
<p><strong>Unix Date Format Examples</strong></p>
<p>lets get the parameter for year , month and date and produce a hyphen separated  date format</p>
<p><strong><em>$date &#8220;+%Y-%m-%d&#8221;</em></strong></p>
<p><strong><em>2010-02-10</em></strong></p>
<p>%Y is keyword for four digit year<br />
%m is keyword for two digit month<br />
%d is keyword for two digit date<br />
Hyphen is separator here .</p>
<p>If you change the separator here  to  slash the format would look like</p>
<p><em><strong>$date &#8220;+%Y/%m/%d&#8221;<br />
2010/02/10</strong></em></p>
<p>You can switch date keyword anyway you want , if you need month first and year last  ,</p>
<p><em><strong>$date &#8220;+%m-%d-%Y&#8221;<br />
02-10-2010</strong></em></p>
<h2>Weekdays </h2>
<p>You can have  additional weekday information in your date with %A as</p>
<p><strong><em>$date &#8220;+%m-%d-%Y %A&#8221;<br />
02-10-2010 Wednesday</em></strong></p>
<p>or</p>
<p><em><strong>$date &#8220;+%A %m-%d-%Y&#8221;<br />
Wednesday 02-10-2010</strong></em></p>
<p>These are options you can select for weekday</p>
<p>%a 	weekday, abbreviated 	Wed<br />
%A 	weekday, full 	Wednesday<br />
%d 	day of the month (dd), zero padded 	10<br />
%e 	day of the month (dd) 	10<br />
%j 	day of year, zero padded 	000-366<br />
%u 	day of week starting with Monday (1), i.e. mtwtfss 	3<br />
%w 	day of week starting with Sunday (0), i.e. smtwtfs 	3</p>
<h2>Month </h2>
<p>You can have additional month information in your date with %B as</p>
<p><strong><em>$date &#8220;+%m-%d-%Y %B&#8221;<br />
02-10-2010 Februrary</em></strong></p>
<p>or</p>
<p><em><strong>$date &#8220;+%B %m-%d-%Y&#8221;<br />
February 02-10-2010</strong></em></p>
<p>These are options you can select for month</p>
<p>%m 	mm month as two digits<br />
%b 	Mon, locale&#8217;s abbreviated 	Feb<br />
%B 	locale&#8217;s full month, variable length 	February</p>
<h2>Year</h2>
<p>You can have additional year information as two digit or four digit with %y or %Y as</p>
<p><em><strong>$date &#8220;+%m-%d-%y &#8221;<br />
02-10-10</strong></em></p>
<p>or</p>
<p><strong><em>$date &#8220;+%m-%d-%Y &#8221;<br />
02-10-2010</em></strong></p>
<p>These are options you can select for year</p>
<p>%y 	yy two digit year 	00–99<br />
%Y 	ccyy year 	2010</p>
<p>Additional date format parameters which can be used :</p>
<h2>Week</h2>
<p>%U 	week number Sunday as first day of week 	01–53<br />
%W 	week number Monday as first day of week 	01–53<br />
%V 	week of the year 	01–53</p>
<h2>Century</h2>
<p>%C 	cc century 	00–99</p>
<h2>Date</h2>
<p>%D 	mm/dd/yy 	02/10/10<br />
%x 	locale&#8217;s date representation (mm/dd/yy) 	02/10/2010<br />
%F 	%Y-%m-%d 	2010-02-10</p>
<h2>Date and Time time stamp</h2>
<p>%c 	locale&#8217;s date and time 	Wed Feb 10 10:02:33 PST 2010</p>
<hr />
<h2>Time function </h2>
<p>Time function is simple to use and date command is used to format &amp; display time as well . You can use date and time parameters to format your date time stamp as per your requirment</p>
<p>A simple time stamp with date  can be generated as :</p>
<p><em><strong>$date &#8220;+%c&#8221;</strong></em><br />
%c 	locale&#8217;s date and time 	Sat Nov 04 12:02:33 EST 1989</p>
<p>Date function have some preformated time stamps to make things easier</p>
<p><strong>Example :</strong></p>
<p><em><strong>$date &#8220;+%r&#8221;<br />
05:28:55 PM</strong></em></p>
<p>More preformated options :</p>
<p>%R 	hours, minutes (24 hour clock) 	hh:mm e.g. 17:28<br />
%T 	hours, minutes, seconds (24-hour clock) 	17:28:55<br />
%X 	locale&#8217;s time representation (%H:%M:%S)       05:28:55 PM</p>
<p>Custom time format</p>
<p>Examples</p>
<p>Time stamp with  12 hr clock</p>
<p><em><strong>$date &#8220;+%l:%M:%S<br />
5:22:45</strong></em></p>
<p>Time stamp with  24 hr clock</p>
<p><em><strong>$date &#8220;+%H:%M:%S&#8221;<br />
20:22:45<br />
</strong></em></p>
<p>Time stamp with  AM/PM</p>
<p><em><strong>$date &#8220;+%l:%M:%S %p&#8221;<br />
5:22:45  PM<br />
</strong></em></p>
<p>Additional date time parameters :</p>
<p><strong>Hours</strong><br />
%l (Lowercase L) 	hour (12 hour clock) 	8<br />
%I (Uppercase I) 	hour (12 hour clock) zero padded 	08<br />
%k 	hour (24 hour clock) 	20<br />
%H 	hour (24 hour clock) zero padded 	20<br />
%p 	locale&#8217;s upper case AM or PM (blank in many locales) 	PM<br />
%P 	locale&#8217;s lower case am or pm (really!) 	pm</p>
<p><strong>Minutes</strong><br />
%M 	MM minutes 	28</p>
<p><strong>Seconds</strong><br />
%s 	seconds since 00:00:00 1970-01-01 UTC (Unix epoch) 	1265833735<br />
%S 	SS second 	00–60<br />
%N 	nanoseconds 	000000000–999999999</p>
<p><strong>Time zone</strong><br />
%z 	-zzzz RFC-822 style numeric timezone 	-0500<br />
%Z 	time zone (e.g., EDT) nothing if no time zone is determinable 	EST</p>
]]></content:encoded>
			<wfw:commentRss>http://adminschoice.com/unix-date-format-examples/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
