<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>date</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<style type="text/css">
body
{
color: black;
background-color: #D5EBFF;
}
h1
{
font: bold 30px Talkhoma, Verdana, Ariel, Sans-Serif;
}
h2
{
font: bold 16px Talkhoma, Verdana, Ariel, Sans-Serif;
}
h3
{
font: bold 14px Talkhoma, Verdana, Ariel, Sans-Serif;
}
p
{
font: normal 14px "New Century Schoolbook", serif;
}
table
{
border-collapse: collapse;
empty-cells: hide;
}
pre
{
font-size: 90%
}
#contents1
{
padding-left: 15%;
width: 70%;
}
#contents2
{
padding-left: 10%;
width:80%;
}
#contents3
{
padding-left: 5%;
width:80%;
}
</style>
</head>
<body>
<div id="contents1">
<h1>date</h1>
<p>date — Format a local time/date</p>
<h2>Description</h2>
<strong>(date format timestamp)</strong> <br />
<p>
Returns a string formatted according to the given format string using the
given integer <i><tt>timestamp</tt></i> or the current time
if no timestamp is given. In other words, <i><tt>timestamp</tt></i>
is optional and defaults to the value of <br /><strong>(get-universal-time)</strong>.
</p>
<h2>Parameters</h2>
</div>
<div id="contents2">
<table summary="The following characters are recognized in the format parameter string" border="1">
<thead><tr>
<th><i><tt>format</tt></i> character</th>
<th>Description</th>
<th>Example returned values</th></tr>
</thead>
<tbody>
<tr>
<td align="center"><span class="emphasis"><em>Day</em></span></td>
<td>---</td>
<td>---</td>
</tr>
<tr>
<td><var>d</var></td>
<td>Day of the month, 2 digits with leading zeros</td>
<td><var>01</var> to <var>31</var></td>
</tr>
<tr>
<td><var>D</var></td>
<td>A textual representation of a day, three letters</td>
<td><var>Mon</var> through <var>Sun</var></td>
</tr>
<tr>
<td><var>j</var></td>
<td>Day of the month without leading zeros</td>
<td><var>1</var> to <var>31</var></td>
</tr>
<tr>
<td><var>l</var> (lowercase 'L')</td>
<td>A full textual representation of the day of the week</td>
<td><var>Sunday</var> through <var>Saturday</var></td>
</tr>
<tr>
<td><var>N</var></td>
<td>ISO-8601 numeric representation of the day of the week </td>
<td><var>1</var> (for Monday) through <var>7</var> (for Sunday)</td>
</tr>
<tr>
<td><var>S</var></td>
<td>English ordinal suffix for the day of the month, 2 characters</td>
<td> <var>st</var>, <var>nd</var>, <var>rd</var> or <var>th</var>. Works well with <var>j</var> </td>
</tr>
<tr>
<td><var>w</var></td>
<td>Numeric representation of the day of the week</td>
<td><var>0</var> (for Sunday) through <var>6</var> (for Saturday)</td>
</tr>
<tr>
<td><var>z</var></td>
<td>The day of the year (starting from 0)</td>
<td><var>0</var> through <var>365</var></td>
</tr>
<tr>
<td align="center"><span class="emphasis"><em>Week</em></span></td>
<td>---</td>
<td>---</td>
</tr>
<tr>
<td><var>W</var></td>
<td>ISO-8601 week number of year, weeks starting on Monday</td>
<td>Example: <var>42</var> (the 42nd week in the year)</td>
</tr>
<tr>
<td align="center"><span class="emphasis"><em>Month</em></span></td>
<td>---</td>
<td>---</td>
</tr>
<tr>
<td><var>F</var></td>
<td>A full textual representation of a month, such as January or March</td>
<td><var>January</var> through <var>December</var></td>
</tr>
<tr>
<td><var>m</var></td>
<td>Numeric representation of a month, with leading zeros</td>
<td><var>01</var> through <var>12</var></td>
</tr>
<tr>
<td><var>M</var></td>
<td>A short textual representation of a month, three letters</td>
<td><var>Jan</var> through <var>Dec</var></td>
</tr>
<tr>
<td><var>n</var></td>
<td>Numeric representation of a month, without leading zeros</td>
<td><var>1</var> through <var>12</var></td>
</tr>
<tr>
<td><var>t</var></td>
<td>Number of days in the given month</td>
<td><var>28</var> through <var>31</var></td>
</tr>
<tr>
<td align="center"><span class="emphasis"><em>Year</em></span></td>
<td>---</td>
<td>---</td>
</tr>
<tr>
<td><var>L</var></td>
<td>Whether it's a leap year</td>
<td><var>1</var> if it is a leap year, <var>0</var> otherwise.</td>
</tr>
<tr>
<td><var>o</var></td>
<td>ISO-8601 year number. This has the same value as <var>Y</var>,
except that if the ISO week number (<var>W</var>) belongs to the previous or next year,
that year is used instead.</td>
<td>Examples: <var>1999</var> or <var>2003</var></td>
</tr>
<tr>
<td><var>Y</var></td>
<td>A full numeric representation of a year, 4 digits</td>
<td>Examples: <var>1999</var> or <var>2003</var></td>
</tr>
<tr>
<td><var>y</var></td>
<td>A two digit representation of a year</td>
<td>Examples: <var>99</var> or <var>03</var></td>
</tr>
<tr>
<td align="center"><span class="emphasis"><em>Time</em></span></td>
<td>---</td>
<td>---</td>
</tr>
<tr>
<td><var>a</var></td>
<td>Lowercase Ante meridiem and Post meridiem</td>
<td><var>am</var> or <var>pm</var></td>
</tr>
<tr>
<td><var>A</var></td>
<td>Uppercase Ante meridiem and Post meridiem</td>
<td><var>AM</var> or <var>PM</var></td>
</tr>
<tr>
<td><var>B</var></td>
<td>Swatch Internet time</td>
<td><var>000</var> through <var>999</var></td>
</tr>
<tr>
<td><var>g</var></td>
<td>12-hour format of an hour without leading zeros</td>
<td><var>1</var> through <var>12</var></td>
</tr>
<tr>
<td><var>G</var></td>
<td>24-hour format of an hour without leading zeros</td>
<td><var>0</var> through <var>23</var></td>
</tr>
<tr>
<td><var>h</var></td>
<td>12-hour format of an hour with leading zeros</td>
<td><var>01</var> through <var>12</var></td>
</tr>
<tr>
<td><var>H</var></td>
<td>24-hour format of an hour with leading zeros</td>
<td><var>00</var> through <var>23</var></td>
</tr>
<tr>
<td><var>i</var></td>
<td>Minutes with leading zeros</td>
<td><var>00</var> to <var>59</var></td>
</tr>
<tr>
<td><var>s</var></td>
<td>Seconds, with leading zeros</td>
<td><var>00</var> through <var>59</var></td>
</tr>
<tr>
<td><var>q</var></td>
<td>milliseconds to three digits with leading zeroes</td>
<td><var>000</var> through <var>999</var></td>
</tr>
<tr>
<td align="center"><span class="emphasis"><em>Timezone</em></span></td>
<td>---</td>
<td>---</td>
</tr>
<tr>
<td><var>e</var></td>
<td>Timezone identifier </td>
<td>Examples: <var>UTC</var>, <var>GMT</var>, <var>Atlantic/Azores</var></td>
</tr>
<tr>
<td><var>I</var> (capital i)</td>
<td>Whether or not the date is in daylight saving time</td>
<td><var>1</var> if Daylight Saving Time, <var>0</var> otherwise.</td>
</tr>
<tr>
<td><var>O</var></td>
<td>Difference to Greenwich time (GMT) in hours</td>
<td>Example: <var>+0200</var></td>
</tr>
<tr>
<td><var>P</var></td>
<td>Difference to Greenwich time (GMT) with colon between hours and minutes</td>
<td>Example: <var>+02:00</var></td>
</tr>
<tr>
<td><var>T</var></td>
<td>Timezone abbreviation</td>
<td>Examples: <var>EST</var>, <var>MDT</var> ...</td>
</tr>
<tr>
<td><var>Z</var></td>
<td>Timezone offset in seconds. The offset for timezones west of UTC is always
negative, and for those east of UTC is always positive.</td>
<td><var>-43200</var> through <var>50400</var></td>
</tr>
<tr>
<td align="center"><span class="emphasis"><em>Full Date/Time</em></span></td>
<td>---</td>
<td>---</td>
</tr>
<tr>
<td><var>c</var></td>
<td>ISO 8601 date</td>
<td>2004-02-12T15:19:21+00:00</td>
</tr>
<tr>
<td><var>r</var></td>
<td><a class="ulink" href="http://www.faqs.org/rfcs/rfc2822" target="_top">» RFC 2822</a>
formatted date</td>
<td>Example: <var>Thu, 21 Dec 2000 16:01:07 +0200</var></td>
</tr>
<tr>
<td><var>U</var></td>
<td>Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)</td>
<td></td>
</tr>
</tbody>
</table>
</div>
<div id="contents1">
<h2>Examples</h2>
<h3>date examples</h3>
</div>
<div id="contents3">
<pre>
;; Prints something like: Monday
(date "l");
;; Prints something like: Monday 15th of August 2005 03:12:46 PM
(date "l dS \\of F Y h:i:s A")
// Prints: July 1, 2000 is on a Sunday
(format t "July 1, 2000 is on a ~A" (date "l", (encode-universal-time 0, 0, 0, 7, 1, 2000)))
;; use the constants in the format parameter
;;prints something like: Mon, 15 Aug 2005 15:12:46 UTC
(date DATE-RFC822)
;; prints something like: 2000-07-01T00:00:00+00:00
(date DATE-ATOM, (encode-universal-time 0, 0, 0, 7, 1, 2000));
</pre>
</div>
<div id="contents1">
<p>
You can prevent a recognized character in the format string from being expanded by escaping
it with a preceding backslash. If the character with a backslash is already a special sequence,
you may need to also escape the backslash. </p>
<p>Example Escaping characters in (date)</p>
</div>
<div id="contents3">
<pre>
;; prints something like: Wednesday the 15th
(write-line date("l \\t\h\e jS"))
</pre>
</div>
<div id="contents1">
<p>
Some examples of (date) formatting. Note that you should escape any other characters, as
any which currently have a special meaning will produce undesirable results, and other
characters may be assigned meaning in future versions.</p>
<h3>date formatting</h3>
</div>
<div id="contents3">
<pre>
;;Assuming today is: March 10th, 2001, 5:16:18 pm
(date "F j, Y, g:i a")
-- "March 10, 2001, 5:16 pm"
(date "m.d.y")
-- "03.10.01"
(date "j, n, Y")
-- "10, 3, 2001"
(date "Ymd")
-- "20010310"
(date 'h-i-s, j-m-y, it is w Day z ')
-- "05-16-17, 10-03-01, 1631 1618 6 Fripm01"
(date '\\i\\t \\i\\s \\t\\h\\e jS \\d\\a\\y.')
-- "It is the 10th day."
(date "D M j G:i:s T Y")
-- "Sat Mar 10 15:16:08 MST 2001"
(date 'H:m:s \\m \\i\\s\\ \\m\\o\\n\\t\\h')
-- "17:03:17 m is month"
(date "H:i:s")
-- "17:16:17"
</pre>
</div>
</body>
</html>