Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Search
Search
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Module:Date/doc
(section)
Module
Discussion
English
Read
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit source
View history
Move
General
What links here
Related changes
Special pages
Page information
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Formatted output == A date can be formatted as text. <syntaxhighlight lang="lua"> local Date = require('Module:Date')._Date local text = Date(2016, 7, 1):text() -- result is '1 July 2016' local text = Date(2016, 7, 1):text('%-d %B') -- result is '1 July' local text = Date('1 July 2016'):text('mdy') -- result is 'July 1, 2016' </syntaxhighlight> The following simplified formatting codes are available. {| class="wikitable" ! Code !! Result |- | hm || hour:minute, with "am" or "pm" or variant, if specified (14:30 or 2:30 pm or variant) |- | hms || hour:minute:second (14:30:45) |- | ymd || year-month-day (2016-07-01) |- | mdy || month day, year (July 1, 2016) |- | dmy || day month year (1 July 2016) |} The following formatting codes (similar to [[strftime]]) are available. {| class="wikitable" ! Code !! Result |- | %a || Day abbreviation: Mon, Tue, ... |- | %A || Day name: Monday, Tuesday, ... |- | %u || Day of week: 1 to 7 (Monday to Sunday) |- | %w || Day of week: 0 to 6 (Sunday to Saturday) |- | %d || Day of month zero-padded: 01 to 31 |- | %b || Month abbreviation: Jan to Dec |- | %B || Month name: January to December |- | %m || Month zero-padded: 01 to 12 |- | %Y || Year zero-padded: 0012, 0120, 1200 |- | %H || Hour 24-hour clock zero-padded: 00 to 23 |- | %I || Hour 12-hour clock zero-padded: 01 to 12 |- | %p || AM or PM or as in options |- | %M || Minute zero-padded: 00 to 59 |- | %S || Second zero-padded: 00 to 59 |- | %j || Day of year zero-padded: 001 to 366 |- | %-d || Day of month: 1 to 31 |- | %-m || Month: 1 to 12 |- | %-Y || Year: 12, 120, 1200 |- | %-H || Hour: 0 to 23 |- | %-M || Minute: 0 to 59 |- | %-S || Second: 0 to 59 |- | %-j || Day of year: 1 to 366 |- | %-I || Hour: 1 to 12 |- | %% || % |} In addition, <code>%{''property''}</code> (where <code>''property''</code> is any property of a date) can be used. For example, <code>Date('1 Feb 2015 14:30:45 A.D.')</code> has the following properties. {| class="wikitable" ! Code !! Result |- | %{calendar} || Gregorian |- | %{year} || 2015 |- | %{month} || 2 |- | %{day} || 1 |- | %{hour} || 14 |- | %{minute} || 30 |- | %{second} || 45 |- | %{dayabbr} || Sun |- | %{dayname} || Sunday |- | %{dayofweek} || 0 |- | %{dow} || 0 (same as dayofweek) |- | %{dayofweekiso} || 7 |- | %{dowiso} || 7 (same as dayofweekiso) |- | %{dayofyear} || 32 |- | %{era} || A.D. |- | %{gsd} || 735630 (numbers of days from 1 January 1 CE; the first is day 1) |- | %{juliandate} || 2457055.1046875 ([[Julian day]]) |- | %{jd} || 2457055.1046875 (same as juliandate) |- | %{isleapyear} || false |- | %{monthdays} || 28 |- | %{monthabbr} || Feb |- | %{monthname} || February |} Some shortcuts are available. Given <code>date = Date('1 Feb 2015 14:30')</code>, the following results would occur. {| class="wikitable" ! Code !! Description !! Example result !! Equivalent format |- | date:text('%c') || date and time || 2:30 pm 1 February 2015 || %-I:%M %p %-d %B %-Y %{era} |- | date:text('%x') || date || 1 February 2015 || %-d %B %-Y %{era} |- | date:text('%X') || time || 2:30 pm || %-I:%M %p |}
Summary:
Please note that all contributions to Ikwipedia are considered to be released under the Creative Commons Attribution-ShareAlike (see
Ikwipedia:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Toggle limited content width