CINXE.COM

Modiwl:Date/doc - Wicipedia

<!DOCTYPE html> <html class="client-nojs vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-sticky-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-feature-night-mode-disabled skin-theme-clientpref-day vector-toc-available" lang="cy" dir="ltr"> <head> <meta charset="UTF-8"> <title>Modiwl:Date/doc - Wicipedia</title> <script>(function(){var className="client-js vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-sticky-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-feature-night-mode-disabled skin-theme-clientpref-day vector-toc-available";var cookie=document.cookie.match(/(?:^|; )cywikimwclientpreferences=([^;]+)/);if(cookie){cookie[1].split('%2C').forEach(function(pref){className=className.replace(new RegExp('(^| )'+pref.replace(/-clientpref-\w+$|[^\w-]+/g,'')+'-clientpref-\\w+( |$)'),'$1'+pref+'$2');});}document.documentElement.className=className;}());RLCONF={"wgBreakFrames":false,"wgSeparatorTransformTable":["",""],"wgDigitTransformTable":["",""],"wgDefaultDateFormat":"dmy" ,"wgMonthNames":["","Ionawr","Chwefror","Mawrth","Ebrill","Mai","Mehefin","Gorffennaf","Awst","Medi","Hydref","Tachwedd","Rhagfyr"],"wgRequestId":"64c1e281-3864-43db-9317-64426ff2b5fe","wgCanonicalNamespace":"Module","wgCanonicalSpecialPageName":false,"wgNamespaceNumber":828,"wgPageName":"Modiwl:Date/doc","wgTitle":"Date/doc","wgCurRevisionId":10910305,"wgRevisionId":10910305,"wgArticleId":287340,"wgIsArticle":true,"wgIsRedirect":false,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":[],"wgPageViewLanguage":"cy","wgPageContentLanguage":"cy","wgPageContentModel":"wikitext","wgRelevantPageName":"Modiwl:Date/doc","wgRelevantArticleId":287340,"wgIsProbablyEditable":true,"wgRelevantPageIsProbablyEditable":true,"wgRestrictionEdit":[],"wgRestrictionMove":[],"wgNoticeProject":"wikipedia","wgCiteReferencePreviewsActive":true,"wgMediaViewerOnClick":true,"wgMediaViewerEnabledByDefault":true,"wgPopupsFlags":0,"wgVisualEditor":{"pageLanguageCode":"cy","pageLanguageDir":"ltr", "pageVariantFallbacks":"cy"},"wgMFDisplayWikibaseDescriptions":{"search":true,"watchlist":true,"tagline":true,"nearby":true},"wgWMESchemaEditAttemptStepOversample":false,"wgWMEPageLength":9000,"wgRelatedArticlesCompat":[],"wgEditSubmitButtonLabelPublish":true,"wgULSPosition":"interlanguage","wgULSisCompactLinksEnabled":false,"wgVector2022LanguageInHeader":true,"wgULSisLanguageSelectorEmpty":false,"wgCheckUserClientHintsHeadersJsApi":["brands","architecture","bitness","fullVersionList","mobile","model","platform","platformVersion"],"GEHomepageSuggestedEditsEnableTopics":true,"wgGETopicsMatchModeEnabled":false,"wgGEStructuredTaskRejectionReasonTextInputEnabled":false,"wgGELevelingUpEnabledForUser":false};RLSTATE={"ext.globalCssJs.user.styles":"ready","site.styles":"ready","user.styles":"ready","ext.globalCssJs.user":"ready","user":"ready","user.options":"loading","ext.pygments":"ready","skins.vector.search.codex.styles":"ready","skins.vector.styles":"ready","skins.vector.icons":"ready", "ext.wikimediamessages.styles":"ready","ext.visualEditor.desktopArticleTarget.noscript":"ready","ext.uls.interlanguage":"ready","wikibase.client.init":"ready","ext.wikimediaBadges":"ready"};RLPAGEMODULES=["ext.pygments.view","site","mediawiki.page.ready","skins.vector.js","ext.centralNotice.geoIP","ext.centralNotice.startUp","ext.urlShortener.toolbar","ext.centralauth.centralautologin","ext.popups","ext.visualEditor.desktopArticleTarget.init","ext.visualEditor.targetLoader","ext.echo.centralauth","ext.eventLogging","ext.wikimediaEvents","ext.navigationTiming","ext.uls.interface","ext.cx.eventlogging.campaigns","ext.checkUser.clientHints"];</script> <script>(RLQ=window.RLQ||[]).push(function(){mw.loader.impl(function(){return["user.options@12s5i",function($,jQuery,require,module){mw.user.tokens.set({"patrolToken":"+\\","watchToken":"+\\","csrfToken":"+\\"}); }];});});</script> <link rel="stylesheet" href="/w/load.php?lang=cy&amp;modules=ext.pygments%2CwikimediaBadges%7Cext.uls.interlanguage%7Cext.visualEditor.desktopArticleTarget.noscript%7Cext.wikimediamessages.styles%7Cskins.vector.icons%2Cstyles%7Cskins.vector.search.codex.styles%7Cwikibase.client.init&amp;only=styles&amp;skin=vector-2022"> <script async="" src="/w/load.php?lang=cy&amp;modules=startup&amp;only=scripts&amp;raw=1&amp;skin=vector-2022"></script> <meta name="ResourceLoaderDynamicStyles" content=""> <link rel="stylesheet" href="/w/load.php?lang=cy&amp;modules=site.styles&amp;only=styles&amp;skin=vector-2022"> <meta name="generator" content="MediaWiki 1.44.0-wmf.5"> <meta name="referrer" content="origin"> <meta name="referrer" content="origin-when-cross-origin"> <meta name="robots" content="max-image-preview:standard"> <meta name="format-detection" content="telephone=no"> <meta name="viewport" content="width=1120"> <meta property="og:title" content="Modiwl:Date/doc - Wicipedia"> <meta property="og:type" content="website"> <link rel="alternate" media="only screen and (max-width: 640px)" href="//cy.m.wikipedia.org/wiki/Modiwl:Date/doc"> <link rel="alternate" type="application/x-wiki" title="Golygu" href="/w/index.php?title=Modiwl:Date/doc&amp;action=edit"> <link rel="apple-touch-icon" href="/static/apple-touch/wikipedia.png"> <link rel="icon" href="/static/favicon/wikipedia.ico"> <link rel="search" type="application/opensearchdescription+xml" href="/w/rest.php/v1/search" title="Wicipedia (cy)"> <link rel="EditURI" type="application/rsd+xml" href="//cy.wikipedia.org/w/api.php?action=rsd"> <link rel="canonical" href="https://cy.wikipedia.org/wiki/Modiwl:Date/doc"> <link rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/deed.cy"> <link rel="alternate" type="application/atom+xml" title="Ffrwd Atom Wicipedia" href="/w/index.php?title=Arbennig:RecentChanges&amp;feed=atom"> <link rel="dns-prefetch" href="//meta.wikimedia.org" /> <link rel="dns-prefetch" href="//login.wikimedia.org"> </head> <body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-828 ns-subject mw-editable page-Modiwl_Date_doc rootpage-Modiwl_Date skin-vector-2022 action-view"><a class="mw-jump-link" href="#bodyContent">Neidio i&#039;r cynnwys</a> <div class="vector-header-container"> <header class="vector-header mw-header"> <div class="vector-header-start"> <nav class="vector-main-menu-landmark" aria-label="Safle"> <div id="vector-main-menu-dropdown" class="vector-dropdown vector-main-menu-dropdown vector-button-flush-left vector-button-flush-right" > <input type="checkbox" id="vector-main-menu-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-main-menu-dropdown" class="vector-dropdown-checkbox " aria-label="Prif ddewislen" > <label id="vector-main-menu-dropdown-label" for="vector-main-menu-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-menu mw-ui-icon-wikimedia-menu"></span> <span class="vector-dropdown-label-text">Prif ddewislen</span> </label> <div class="vector-dropdown-content"> <div id="vector-main-menu-unpinned-container" class="vector-unpinned-container"> <div id="vector-main-menu" class="vector-main-menu vector-pinnable-element"> <div class="vector-pinnable-header vector-main-menu-pinnable-header vector-pinnable-header-unpinned" data-feature-name="main-menu-pinned" data-pinnable-element-id="vector-main-menu" data-pinned-container-id="vector-main-menu-pinned-container" data-unpinned-container-id="vector-main-menu-unpinned-container" > <div class="vector-pinnable-header-label">Prif ddewislen</div> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-main-menu.pin">symud i&#039;r bar ochr</button> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-main-menu.unpin">cuddio</button> </div> <div id="p-navigation" class="vector-menu mw-portlet mw-portlet-navigation" > <div class="vector-menu-heading"> Panel llywio </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="n-mainpage" class="mw-list-item"><a href="/wiki/Hafan" title="Ymweld â&#039;r Hafan [z]" accesskey="z"><span>Hafan</span></a></li><li id="n-portal" class="mw-list-item"><a href="/wiki/Wicipedia:Porth_y_Gymuned" title="Pethau i&#039;w gwneud, adnoddau a thudalennau&#039;r gymuned"><span>Porth y Gymuned</span></a></li><li id="n-cafe" class="mw-list-item"><a href="/wiki/Wicipedia:Y_Caffi"><span>Y Caffi</span></a></li><li id="n-currentevents" class="mw-list-item"><a href="/wiki/Categori:Materion_cyfoes" title="Gwybodaeth yn gysylltiedig â materion cyfoes"><span>Materion cyfoes</span></a></li><li id="n-recentchanges" class="mw-list-item"><a href="/wiki/Arbennig:RecentChanges" title="Rhestr y newidiadau diweddar ar y wici. [r]" accesskey="r"><span>Newidiadau diweddar</span></a></li><li id="n-randompage" class="mw-list-item"><a href="/wiki/Arbennig:Random" title="Llwytho tudalen ar hap [x]" accesskey="x"><span>Erthygl ar hap</span></a></li><li id="n-help" class="mw-list-item"><a href="/wiki/Wicipedia:Cymorth" title="Tudalennau cymorth"><span>Cymorth</span></a></li> </ul> </div> </div> </div> </div> </div> </div> </nav> <a href="/wiki/Hafan" class="mw-logo"> <img class="mw-logo-icon" src="/static/images/icons/wikipedia.png" alt="" aria-hidden="true" height="50" width="50"> <span class="mw-logo-container skin-invert"> <img class="mw-logo-wordmark" alt="Wicipedia" src="/static/images/mobile/copyright/wikipedia-wordmark-cy.svg" style="width: 7.5em; height: 1.125em;"> <img class="mw-logo-tagline" alt="" src="/static/images/mobile/copyright/wikipedia-tagline-cy.svg" width="120" height="13" style="width: 7.5em; height: 0.8125em;"> </span> </a> </div> <div class="vector-header-end"> <div id="p-search" role="search" class="vector-search-box-vue vector-search-box-collapses vector-search-box-show-thumbnail vector-search-box-auto-expand-width vector-search-box"> <a href="/wiki/Arbennig:Search" class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only search-toggle" title="Chwilio Wicipedia [f]" accesskey="f"><span class="vector-icon mw-ui-icon-search mw-ui-icon-wikimedia-search"></span> <span>Chwilio</span> </a> <div class="vector-typeahead-search-container"> <div class="cdx-typeahead-search cdx-typeahead-search--show-thumbnail cdx-typeahead-search--auto-expand-width"> <form action="/w/index.php" id="searchform" class="cdx-search-input cdx-search-input--has-end-button"> <div id="simpleSearch" class="cdx-search-input__input-wrapper" data-search-loc="header-moved"> <div class="cdx-text-input cdx-text-input--has-start-icon"> <input class="cdx-text-input__input" type="search" name="search" placeholder="Chwilio Wicipedia" aria-label="Chwilio Wicipedia" autocapitalize="sentences" title="Chwilio Wicipedia [f]" accesskey="f" id="searchInput" > <span class="cdx-text-input__icon cdx-text-input__start-icon"></span> </div> <input type="hidden" name="title" value="Arbennig:Search"> </div> <button class="cdx-button cdx-search-input__end-button">Chwilio</button> </form> </div> </div> </div> <nav class="vector-user-links vector-user-links-wide" aria-label="Offer personol"> <div class="vector-user-links-main"> <div id="p-vector-user-menu-preferences" class="vector-menu mw-portlet emptyPortlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </div> <div id="p-vector-user-menu-userpage" class="vector-menu mw-portlet emptyPortlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </div> <nav class="vector-appearance-landmark" aria-label="Gwedd"> <div id="vector-appearance-dropdown" class="vector-dropdown " title="Newidiwch ymddangosiad maint ffont, lled a lliw y dudalen" > <input type="checkbox" id="vector-appearance-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-appearance-dropdown" class="vector-dropdown-checkbox " aria-label="Gwedd" > <label id="vector-appearance-dropdown-label" for="vector-appearance-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-appearance mw-ui-icon-wikimedia-appearance"></span> <span class="vector-dropdown-label-text">Gwedd</span> </label> <div class="vector-dropdown-content"> <div id="vector-appearance-unpinned-container" class="vector-unpinned-container"> </div> </div> </div> </nav> <div id="p-vector-user-menu-notifications" class="vector-menu mw-portlet emptyPortlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </div> <div id="p-vector-user-menu-overflow" class="vector-menu mw-portlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="pt-sitesupport-2" class="user-links-collapsible-item mw-list-item user-links-collapsible-item"><a data-mw="interface" href="//donate.wikimedia.org/wiki/Special:FundraiserRedirector?utm_source=donate&amp;utm_medium=sidebar&amp;utm_campaign=C13_cy.wikipedia.org&amp;uselang=cy" class=""><span>Rhoi</span></a> </li> <li id="pt-createaccount-2" class="user-links-collapsible-item mw-list-item user-links-collapsible-item"><a data-mw="interface" href="/w/index.php?title=Arbennig:CreateAccount&amp;returnto=Modiwl%3ADate%2Fdoc" title="Rydym yn argymell eich bod yn creu cyfri ac yn menwgofnodi. Fodd bynnag, dydy hyn ddim yn orfodol" class=""><span>Creu cyfrif</span></a> </li> <li id="pt-login-2" class="user-links-collapsible-item mw-list-item user-links-collapsible-item"><a data-mw="interface" href="/w/index.php?title=Arbennig:UserLogin&amp;returnto=Modiwl%3ADate%2Fdoc" title="Fe&#039;ch anogir i fewngofnodi, er nad oes rhaid gwneud. [o]" accesskey="o" class=""><span>Mewngofnodi</span></a> </li> </ul> </div> </div> </div> <div id="vector-user-links-dropdown" class="vector-dropdown vector-user-menu vector-button-flush-right vector-user-menu-logged-out" title="Rhagor o opsiynau" > <input type="checkbox" id="vector-user-links-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-user-links-dropdown" class="vector-dropdown-checkbox " aria-label="Offer personol" > <label id="vector-user-links-dropdown-label" for="vector-user-links-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-ellipsis mw-ui-icon-wikimedia-ellipsis"></span> <span class="vector-dropdown-label-text">Offer personol</span> </label> <div class="vector-dropdown-content"> <div id="p-personal" class="vector-menu mw-portlet mw-portlet-personal user-links-collapsible-item" title="Dewislen defnyddiwr" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="pt-sitesupport" class="user-links-collapsible-item mw-list-item"><a href="//donate.wikimedia.org/wiki/Special:FundraiserRedirector?utm_source=donate&amp;utm_medium=sidebar&amp;utm_campaign=C13_cy.wikipedia.org&amp;uselang=cy"><span>Rhoi</span></a></li><li id="pt-createaccount" class="user-links-collapsible-item mw-list-item"><a href="/w/index.php?title=Arbennig:CreateAccount&amp;returnto=Modiwl%3ADate%2Fdoc" title="Rydym yn argymell eich bod yn creu cyfri ac yn menwgofnodi. Fodd bynnag, dydy hyn ddim yn orfodol"><span class="vector-icon mw-ui-icon-userAdd mw-ui-icon-wikimedia-userAdd"></span> <span>Creu cyfrif</span></a></li><li id="pt-login" class="user-links-collapsible-item mw-list-item"><a href="/w/index.php?title=Arbennig:UserLogin&amp;returnto=Modiwl%3ADate%2Fdoc" title="Fe&#039;ch anogir i fewngofnodi, er nad oes rhaid gwneud. [o]" accesskey="o"><span class="vector-icon mw-ui-icon-logIn mw-ui-icon-wikimedia-logIn"></span> <span>Mewngofnodi</span></a></li> </ul> </div> </div> <div id="p-user-menu-anon-editor" class="vector-menu mw-portlet mw-portlet-user-menu-anon-editor" > <div class="vector-menu-heading"> Tudalennau ar gyfer golygyddion allgofnodedig <a href="/wiki/Cymorth:Cyflwyniad" aria-label="Dysgu mwy am olygu"><span>dysgu mwy</span></a> </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="pt-anoncontribs" class="mw-list-item"><a href="/wiki/Arbennig:MyContributions" title="Rhestr golygiadau o&#039;r cyfeiriad IP hwn [y]" accesskey="y"><span>Cyfraniadau</span></a></li><li id="pt-anontalk" class="mw-list-item"><a href="/wiki/Arbennig:MyTalk" title="Sgwrs ynglŷn â golygiadau o&#039;r cyfeiriad IP hwn [n]" accesskey="n"><span>Sgwrs</span></a></li> </ul> </div> </div> </div> </div> </nav> </div> </header> </div> <div class="mw-page-container"> <div class="mw-page-container-inner"> <div class="vector-sitenotice-container"> <div id="siteNotice"><!-- CentralNotice --></div> </div> <div class="vector-column-start"> <div class="vector-main-menu-container"> <div id="mw-navigation"> <nav id="mw-panel" class="vector-main-menu-landmark" aria-label="Safle"> <div id="vector-main-menu-pinned-container" class="vector-pinned-container"> </div> </nav> </div> </div> <div class="vector-sticky-pinned-container"> <nav id="mw-panel-toc" aria-label="Cynnwys" data-event-name="ui.sidebar-toc" class="mw-table-of-contents-container vector-toc-landmark"> <div id="vector-toc-pinned-container" class="vector-pinned-container"> <div id="vector-toc" class="vector-toc vector-pinnable-element"> <div class="vector-pinnable-header vector-toc-pinnable-header vector-pinnable-header-pinned" data-feature-name="toc-pinned" data-pinnable-element-id="vector-toc" > <h2 class="vector-pinnable-header-label">Cynnwys</h2> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-toc.pin">symud i&#039;r bar ochr</button> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-toc.unpin">cuddio</button> </div> <ul class="vector-toc-contents" id="mw-panel-toc-list"> <li id="toc-mw-content-text" class="vector-toc-list-item vector-toc-level-1"> <a href="#" class="vector-toc-link"> <div class="vector-toc-text">Y dechrau</div> </a> </li> <li id="toc-Formatted_output" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#Formatted_output"> <div class="vector-toc-text"> <span class="vector-toc-numb">1</span> <span>Formatted output</span> </div> </a> <ul id="toc-Formatted_output-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Julian_date" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#Julian_date"> <div class="vector-toc-text"> <span class="vector-toc-numb">2</span> <span>Julian date</span> </div> </a> <ul id="toc-Julian_date-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Date_differences" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#Date_differences"> <div class="vector-toc-text"> <span class="vector-toc-numb">3</span> <span>Date differences</span> </div> </a> <ul id="toc-Date_differences-sublist" class="vector-toc-list"> </ul> </li> </ul> </div> </div> </nav> </div> </div> <div class="mw-content-container"> <main id="content" class="mw-body"> <header class="mw-body-header vector-page-titlebar"> <nav aria-label="Cynnwys" class="vector-toc-landmark"> <div id="vector-page-titlebar-toc" class="vector-dropdown vector-page-titlebar-toc vector-button-flush-left" > <input type="checkbox" id="vector-page-titlebar-toc-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-page-titlebar-toc" class="vector-dropdown-checkbox " aria-label="Toglo&#039;r tabl cynnwys" > <label id="vector-page-titlebar-toc-label" for="vector-page-titlebar-toc-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-listBullet mw-ui-icon-wikimedia-listBullet"></span> <span class="vector-dropdown-label-text">Toglo&#039;r tabl cynnwys</span> </label> <div class="vector-dropdown-content"> <div id="vector-page-titlebar-toc-unpinned-container" class="vector-unpinned-container"> </div> </div> </div> </nav> <h1 id="firstHeading" class="firstHeading mw-first-heading"><span class="mw-page-title-namespace">Modiwl</span><span class="mw-page-title-separator">:</span><span class="mw-page-title-main">Date/doc</span></h1> <div id="p-lang-btn" class="vector-dropdown mw-portlet mw-portlet-lang" > <input type="checkbox" id="p-lang-btn-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-p-lang-btn" class="vector-dropdown-checkbox mw-interlanguage-selector" aria-label="Mae&#039;r erthygl hon ar gael yn yr iaith hon yn unig. Ychwanegwch yr erthygl mewn ieithoedd eraill" > <label id="p-lang-btn-label" for="p-lang-btn-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--action-progressive mw-portlet-lang-heading-0" aria-hidden="true" ><span class="vector-icon mw-ui-icon-language-progressive mw-ui-icon-wikimedia-language-progressive"></span> <span class="vector-dropdown-label-text">Ychwanegu ieithoedd</span> </label> <div class="vector-dropdown-content"> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> <div class="after-portlet after-portlet-lang"><span class="uls-after-portlet-link"></span><span class="wb-langlinks-add wb-langlinks-link"><a href="https://www.wikidata.org/wiki/Special:NewItem?site=cywiki&amp;page=Modiwl%3ADate%2Fdoc" title="Ychwanegu dolenni rhyngwici" class="wbc-editpage">Ychwanegu dolenni</a></span></div> </div> </div> </div> </header> <div class="vector-page-toolbar"> <div class="vector-page-toolbar-container"> <div id="left-navigation"> <nav aria-label="Parthau"> <div id="p-associated-pages" class="vector-menu vector-menu-tabs mw-portlet mw-portlet-associated-pages" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="ca-nstab-module" class="selected vector-tab-noicon mw-list-item"><a href="/wiki/Modiwl:Date/doc" title="Gweld tudalen y modiwl [c]" accesskey="c"><span>Modiwl</span></a></li><li id="ca-talk" class="new vector-tab-noicon mw-list-item"><a href="/w/index.php?title=Sgwrs_modiwl:Date/doc&amp;action=edit&amp;redlink=1" rel="discussion" class="new" title="Sgwrsio am y dudalen (dim tudalen ar gael) [t]" accesskey="t"><span>Sgwrs</span></a></li> </ul> </div> </div> <div id="vector-variants-dropdown" class="vector-dropdown emptyPortlet" > <input type="checkbox" id="vector-variants-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-variants-dropdown" class="vector-dropdown-checkbox " aria-label="Newid amrywiad iaith" > <label id="vector-variants-dropdown-label" for="vector-variants-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet" aria-hidden="true" ><span class="vector-dropdown-label-text">Cymraeg</span> </label> <div class="vector-dropdown-content"> <div id="p-variants" class="vector-menu mw-portlet mw-portlet-variants emptyPortlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </div> </div> </div> </nav> </div> <div id="right-navigation" class="vector-collapsible"> <nav aria-label="Golygon"> <div id="p-views" class="vector-menu vector-menu-tabs mw-portlet mw-portlet-views" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="ca-view" class="selected vector-tab-noicon mw-list-item"><a href="/wiki/Modiwl:Date/doc"><span>Darllen</span></a></li><li id="ca-edit" class="vector-tab-noicon mw-list-item"><a href="/w/index.php?title=Modiwl:Date/doc&amp;action=edit" title="Golygu cod ffynhonnell y dudalen hon [e]" accesskey="e"><span>Golygu cod</span></a></li><li id="ca-history" class="vector-tab-noicon mw-list-item"><a href="/w/index.php?title=Modiwl:Date/doc&amp;action=history" title="Fersiynau cynt o&#039;r dudalen hon. [h]" accesskey="h"><span>Gweld hanes</span></a></li> </ul> </div> </div> </nav> <nav class="vector-page-tools-landmark" aria-label="Offer tudalen"> <div id="vector-page-tools-dropdown" class="vector-dropdown vector-page-tools-dropdown" > <input type="checkbox" id="vector-page-tools-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-page-tools-dropdown" class="vector-dropdown-checkbox " aria-label="Blwch offer" > <label id="vector-page-tools-dropdown-label" for="vector-page-tools-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet" aria-hidden="true" ><span class="vector-dropdown-label-text">Blwch offer</span> </label> <div class="vector-dropdown-content"> <div id="vector-page-tools-unpinned-container" class="vector-unpinned-container"> <div id="vector-page-tools" class="vector-page-tools vector-pinnable-element"> <div class="vector-pinnable-header vector-page-tools-pinnable-header vector-pinnable-header-unpinned" data-feature-name="page-tools-pinned" data-pinnable-element-id="vector-page-tools" data-pinned-container-id="vector-page-tools-pinned-container" data-unpinned-container-id="vector-page-tools-unpinned-container" > <div class="vector-pinnable-header-label">Blwch offer</div> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-page-tools.pin">symud i&#039;r bar ochr</button> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-page-tools.unpin">cuddio</button> </div> <div id="p-cactions" class="vector-menu mw-portlet mw-portlet-cactions emptyPortlet vector-has-collapsible-items" title="Rhagor o opsiynau" > <div class="vector-menu-heading"> Gweithredoedd </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="ca-more-view" class="selected vector-more-collapsible-item mw-list-item"><a href="/wiki/Modiwl:Date/doc"><span>Darllen</span></a></li><li id="ca-more-edit" class="vector-more-collapsible-item mw-list-item"><a href="/w/index.php?title=Modiwl:Date/doc&amp;action=edit" title="Golygu cod ffynhonnell y dudalen hon [e]" accesskey="e"><span>Golygu cod</span></a></li><li id="ca-more-history" class="vector-more-collapsible-item mw-list-item"><a href="/w/index.php?title=Modiwl:Date/doc&amp;action=history"><span>Gweld hanes</span></a></li> </ul> </div> </div> <div id="p-tb" class="vector-menu mw-portlet mw-portlet-tb" > <div class="vector-menu-heading"> Cyffredinol </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="t-whatlinkshere" class="mw-list-item"><a href="/wiki/Arbennig:WhatLinksHere/Modiwl:Date/doc" title="Rhestr o bob tudalen sy&#039;n cysylltu â hon [j]" accesskey="j"><span>Beth sy'n cysylltu yma</span></a></li><li id="t-recentchangeslinked" class="mw-list-item"><a href="/wiki/Arbennig:RecentChangesLinked/Modiwl:Date/doc" rel="nofollow" title="Newidiadau diweddar i dudalennau sydd yn cysylltu â hon [k]" accesskey="k"><span>Newidiadau perthnasol</span></a></li><li id="t-specialpages" class="mw-list-item"><a href="/wiki/Arbennig:SpecialPages" title="Rhestr o&#039;r holl dudalennau arbennig [q]" accesskey="q"><span>Tudalennau arbennig</span></a></li><li id="t-permalink" class="mw-list-item"><a href="/w/index.php?title=Modiwl:Date/doc&amp;oldid=10910305" title="Dolen barhaol i&#039;r fersiwn hwn y dudalen hon"><span>Dolen barhaol</span></a></li><li id="t-info" class="mw-list-item"><a href="/w/index.php?title=Modiwl:Date/doc&amp;action=info" title="Mwy o wybodaeth am y dudalen hon"><span>Gwybodaeth am y dudalen</span></a></li><li id="t-urlshortener" class="mw-list-item"><a href="/w/index.php?title=Arbennig:UrlShortener&amp;url=https%3A%2F%2Fcy.wikipedia.org%2Fwiki%2FModiwl%3ADate%2Fdoc"><span>Cael URL byr</span></a></li><li id="t-urlshortener-qrcode" class="mw-list-item"><a href="/w/index.php?title=Arbennig:QrCode&amp;url=https%3A%2F%2Fcy.wikipedia.org%2Fwiki%2FModiwl%3ADate%2Fdoc"><span>Lawrlwytho cod QR</span></a></li> </ul> </div> </div> <div id="p-electronpdfservice-sidebar-portlet-heading" class="vector-menu mw-portlet mw-portlet-electronpdfservice-sidebar-portlet-heading" > <div class="vector-menu-heading"> Argraffu / allforio </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="electron-print_pdf" class="mw-list-item"><a href="/w/index.php?title=Arbennig:DownloadAsPdf&amp;page=Modiwl%3ADate%2Fdoc&amp;action=show-download-screen"><span>Lawrlwytho fel PDF</span></a></li><li id="t-print" class="mw-list-item"><a href="javascript:print();" rel="alternate" title="Cynhyrchwch fersiwn o&#039;r dudalen yn barod at ei hargraffu [p]" accesskey="p"><span>Fersiwn argraffu</span></a></li> </ul> </div> </div> <div id="p-wikibase-otherprojects" class="vector-menu mw-portlet mw-portlet-wikibase-otherprojects emptyPortlet" > <div class="vector-menu-heading"> Mewn prosiectau eraill </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </div> </div> </div> </div> </div> </nav> </div> </div> </div> <div class="vector-column-end"> <div class="vector-sticky-pinned-container"> <nav class="vector-page-tools-landmark" aria-label="Offer tudalen"> <div id="vector-page-tools-pinned-container" class="vector-pinned-container"> </div> </nav> <nav class="vector-appearance-landmark" aria-label="Gwedd"> <div id="vector-appearance-pinned-container" class="vector-pinned-container"> <div id="vector-appearance" class="vector-appearance vector-pinnable-element"> <div class="vector-pinnable-header vector-appearance-pinnable-header vector-pinnable-header-pinned" data-feature-name="appearance-pinned" data-pinnable-element-id="vector-appearance" data-pinned-container-id="vector-appearance-pinned-container" data-unpinned-container-id="vector-appearance-unpinned-container" > <div class="vector-pinnable-header-label">Gwedd</div> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-appearance.pin">symud i&#039;r bar ochr</button> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-appearance.unpin">cuddio</button> </div> </div> </div> </nav> </div> </div> <div id="bodyContent" class="vector-body" aria-labelledby="firstHeading" data-mw-ve-target-container> <div class="vector-body-before-content"> <div class="mw-indicators"> </div> <div id="siteSub" class="noprint">Oddi ar Wicipedia</div> </div> <div id="contentSub"><div id="mw-content-subtitle"><div class="subpages">&lt; <bdi dir="ltr"><a href="/wiki/Modiwl:Date" title="Modiwl:Date">Modiwl:Date</a></bdi></div></div></div> <div id="mw-content-text" class="mw-body-content"><p><b>This is the documentation page for <a href="/wiki/Modiwl:Date" title="Modiwl:Date">Modiwl:Date</a></b> </p><div class="mw-content-ltr mw-parser-output" lang="cy" dir="ltr"><p>This module provides date functions for use by other modules. Dates in the <a href="/w/index.php?title=Gregorian_calendar&amp;action=edit&amp;redlink=1" class="new" title="Gregorian calendar (dim tudalen ar gael)">Gregorian calendar</a> and the <a href="/w/index.php?title=Julian_calendar&amp;action=edit&amp;redlink=1" class="new" title="Julian calendar (dim tudalen ar gael)">Julian calendar</a> are supported, from 9999 BCE to 9999 CE. The calendars are proleptic—they are assumed to apply at all times with no irregularities. </p><p>A date, with an optional time, can be specified in a variety of formats, and can be converted for display using a variety of formats, for example, 1 April 2016 or April 1, 2016. The properties of a date include its <a href="/w/index.php?title=Julian_day&amp;action=edit&amp;redlink=1" class="new" title="Julian day (dim tudalen ar gael)">Julian date</a> and its <a href="/w/index.php?title=Gregorian_date&amp;action=edit&amp;redlink=1" class="new" title="Gregorian date (dim tudalen ar gael)">Gregorian</a> serial date, as well as the day-of-week and day-of-year. </p><p>Dates can be compared (for example, <code>date1 &lt;= date2</code>), and can be used with add or subtract (for example, <code>date + '3 months'</code>). The difference between two dates can be determined with <code>date1 - date2</code>. These operations work with both Gregorian and Julian calendar dates, but <code>date1 - date2</code> is nil if the two dates use different calendars. </p><p>The module provides the following items. </p> <table class="wikitable"> <tbody><tr> <th>Export</th> <th>Description </th></tr> <tr> <td><code>_current</code></td> <td>Table with the current year, month, day, hour, minute, second. </td></tr> <tr> <td><code>_Date</code></td> <td>Function that returns a table for a specified date. </td></tr> <tr> <td><code>_days_in_month</code></td> <td>Function that returns the number of days in a month. </td></tr></tbody></table> <p>The following has examples of using the module: </p> <ul><li><a href="/w/index.php?title=Modiwl:Date/example&amp;action=edit&amp;redlink=1" class="new" title="Modiwl:Date/example (dim tudalen ar gael)">Module:Date/example</a> • Demonstration showing how Module:Date may be used.</li> <li><a href="/w/index.php?title=Sgwrs_modiwl:Date/example&amp;action=edit&amp;redlink=1" class="new" title="Sgwrs modiwl:Date/example (dim tudalen ar gael)">Module talk:Date/example</a> • Output from the demonstration.</li></ul> <div class="mw-heading mw-heading2"><h2 id="Formatted_output">Formatted output</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Modiwl:Date/doc&amp;action=edit&amp;section=1" title="Edit section&#039;s source code: Formatted output"><span>golygu cod</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>A date can be formatted as text. </p> <div class="mw-highlight mw-highlight-lang-lua mw-content-ltr" dir="ltr"><pre><span></span><span class="kd">local</span> <span class="n">Date</span> <span class="o">=</span> <span class="nb">require</span><span class="p">(</span><span class="s1">&#39;Module:Date&#39;</span><span class="p">).</span><span class="n">_Date</span> <span class="kd">local</span> <span class="n">text</span> <span class="o">=</span> <span class="n">Date</span><span class="p">(</span><span class="mi">2016</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">1</span><span class="p">):</span><span class="n">text</span><span class="p">()</span> <span class="c1">-- result is &#39;1 July 2016&#39;</span> <span class="kd">local</span> <span class="n">text</span> <span class="o">=</span> <span class="n">Date</span><span class="p">(</span><span class="mi">2016</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">1</span><span class="p">):</span><span class="n">text</span><span class="p">(</span><span class="s1">&#39;%-d %B&#39;</span><span class="p">)</span> <span class="c1">-- result is &#39;1 July&#39;</span> <span class="kd">local</span> <span class="n">text</span> <span class="o">=</span> <span class="n">Date</span><span class="p">(</span><span class="s1">&#39;1 July 2016&#39;</span><span class="p">):</span><span class="n">text</span><span class="p">(</span><span class="s1">&#39;mdy&#39;</span><span class="p">)</span> <span class="c1">-- result is &#39;July 1, 2016&#39;</span> </pre></div> <p>The following simplified formatting codes are available. </p> <table class="wikitable"> <tbody><tr> <th>Code</th> <th>Result </th></tr> <tr> <td>hm</td> <td>hour:minute, with "am" or "pm" or variant, if specified (14:30 or 2:30&#160;pm or variant) </td></tr> <tr> <td>hms</td> <td>hour:minute:second (14:30:45) </td></tr> <tr> <td>ymd</td> <td>year-month-day (2016-07-01) </td></tr> <tr> <td>mdy</td> <td>month day, year (July 1, 2016) </td></tr> <tr> <td>dmy</td> <td>day month year (1 July 2016) </td></tr></tbody></table> <p>The following formatting codes (similar to <a href="/w/index.php?title=Strftime&amp;action=edit&amp;redlink=1" class="new" title="Strftime (dim tudalen ar gael)">strftime</a>) are available. </p> <table class="wikitable"> <tbody><tr> <th>Code</th> <th>Result </th></tr> <tr> <td>%a</td> <td>Day abbreviation: Mon, Tue, ... </td></tr> <tr> <td>%A</td> <td>Day name: Monday, Tuesday, ... </td></tr> <tr> <td>%u</td> <td>Day of week: 1 to 7 (Monday to Sunday) </td></tr> <tr> <td>%w</td> <td>Day of week: 0 to 6 (Sunday to Saturday) </td></tr> <tr> <td>%d</td> <td>Day of month zero-padded: 01 to 31 </td></tr> <tr> <td>%b</td> <td>Month abbreviation: Jan to Dec </td></tr> <tr> <td>%B</td> <td>Month name: January to December </td></tr> <tr> <td>%m</td> <td>Month zero-padded: 01 to 12 </td></tr> <tr> <td>%Y</td> <td>Year zero-padded: 0012, 0120, 1200 </td></tr> <tr> <td>%H</td> <td>Hour 24-hour clock zero-padded: 00 to 23 </td></tr> <tr> <td>%I</td> <td>Hour 12-hour clock zero-padded: 01 to 12 </td></tr> <tr> <td>%p</td> <td>AM or PM or as in options </td></tr> <tr> <td>%M</td> <td>Minute zero-padded: 00 to 59 </td></tr> <tr> <td>%S</td> <td>Second zero-padded: 00 to 59 </td></tr> <tr> <td>%j</td> <td>Day of year zero-padded: 001 to 366 </td></tr> <tr> <td>%-d</td> <td>Day of month: 1 to 31 </td></tr> <tr> <td>%-m</td> <td>Month: 1 to 12 </td></tr> <tr> <td>%-Y</td> <td>Year: 12, 120, 1200 </td></tr> <tr> <td>%-H</td> <td>Hour: 0 to 23 </td></tr> <tr> <td>%-M</td> <td>Minute: 0 to 59 </td></tr> <tr> <td>%-S</td> <td>Second: 0 to 59 </td></tr> <tr> <td>%-j</td> <td>Day of year: 1 to 366 </td></tr> <tr> <td>%-I</td> <td>Hour: 1 to 12 </td></tr> <tr> <td>%%</td> <td>% </td></tr></tbody></table> <p>In addition, <code>%{<i>property</i>}</code> (where <code><i>property</i></code> is any property of a date) can be used. </p><p>For example, <code>Date('1 Feb 2015 14:30:45 A.D.')</code> has the following properties. </p> <table class="wikitable"> <tbody><tr> <th>Code</th> <th>Result </th></tr> <tr> <td>%{calendar}</td> <td>Gregorian </td></tr> <tr> <td>%{year}</td> <td>2015 </td></tr> <tr> <td>%{month}</td> <td>2 </td></tr> <tr> <td>%{day}</td> <td>1 </td></tr> <tr> <td>%{hour}</td> <td>14 </td></tr> <tr> <td>%{minute}</td> <td>30 </td></tr> <tr> <td>%{second}</td> <td>45 </td></tr> <tr> <td>%{dayabbr}</td> <td>Sun </td></tr> <tr> <td>%{dayname}</td> <td>Sunday </td></tr> <tr> <td>%{dayofweek}</td> <td>0 </td></tr> <tr> <td>%{dow}</td> <td>0 (same as dayofweek) </td></tr> <tr> <td>%{dayofweekiso}</td> <td>7 </td></tr> <tr> <td>%{dowiso}</td> <td>7 (same as dayofweekiso) </td></tr> <tr> <td>%{dayofyear}</td> <td>32 </td></tr> <tr> <td>%{era}</td> <td>A.D. </td></tr> <tr> <td>%{gsd}</td> <td>735630 (numbers of days from 1 January 1 CE; the first is day 1) </td></tr> <tr> <td>%{juliandate}</td> <td>2457055.1046875 (<a href="/w/index.php?title=Julian_day&amp;action=edit&amp;redlink=1" class="new" title="Julian day (dim tudalen ar gael)">Julian day</a>) </td></tr> <tr> <td>%{jd}</td> <td>2457055.1046875 (same as juliandate) </td></tr> <tr> <td>%{isleapyear}</td> <td>false </td></tr> <tr> <td>%{monthdays}</td> <td>28 </td></tr> <tr> <td>%{monthabbr}</td> <td>Feb </td></tr> <tr> <td>%{monthname}</td> <td>February </td></tr></tbody></table> <p>Some shortcuts are available. Given <code>date = Date('1 Feb 2015 14:30')</code>, the following results would occur. </p> <table class="wikitable"> <tbody><tr> <th>Code</th> <th>Description</th> <th>Example result</th> <th>Equivalent format </th></tr> <tr> <td>date:text('%c')</td> <td>date and time</td> <td>2:30&#160;pm 1 February 2015</td> <td>%-I:%M %p&#160;%-d %B&#160;%-Y&#160;%{era} </td></tr> <tr> <td>date:text('%x')</td> <td>date</td> <td>1 February 2015</td> <td>%-d %B&#160;%-Y&#160;%{era} </td></tr> <tr> <td>date:text('%X')</td> <td>time</td> <td>2:30&#160;pm</td> <td>%-I:%M %p </td></tr></tbody></table> <div class="mw-heading mw-heading2"><h2 id="Julian_date">Julian date</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Modiwl:Date/doc&amp;action=edit&amp;section=2" title="Edit section&#039;s source code: Julian date"><span>golygu cod</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>The following has an example of converting a <a href="/w/index.php?title=Julian_day&amp;action=edit&amp;redlink=1" class="new" title="Julian day (dim tudalen ar gael)">Julian date</a> to a date, then obtaining information about the date. </p> <div class="mw-highlight mw-highlight-lang-lua mw-content-ltr" dir="ltr"><pre><span></span><span class="c1">-- Code -- Result</span> <span class="n">Date</span> <span class="o">=</span> <span class="nb">require</span><span class="p">(</span><span class="s1">&#39;Module:Date&#39;</span><span class="p">).</span><span class="n">_Date</span> <span class="n">date</span> <span class="o">=</span> <span class="n">Date</span><span class="p">(</span><span class="s1">&#39;juliandate&#39;</span><span class="p">,</span> <span class="mi">320</span><span class="p">)</span> <span class="n">number</span> <span class="o">=</span> <span class="n">date</span><span class="p">.</span><span class="n">gsd</span> <span class="c1">-- -1721105</span> <span class="n">number</span> <span class="o">=</span> <span class="n">date</span><span class="p">.</span><span class="n">jd</span> <span class="c1">-- 320</span> <span class="n">text</span> <span class="o">=</span> <span class="n">date</span><span class="p">.</span><span class="n">dayname</span> <span class="c1">-- Saturday</span> <span class="n">text</span> <span class="o">=</span> <span class="n">date</span><span class="p">:</span><span class="n">text</span><span class="p">()</span> <span class="c1">-- 9 October 4713&amp;nbsp;BC</span> <span class="n">text</span> <span class="o">=</span> <span class="n">date</span><span class="p">:</span><span class="n">text</span><span class="p">(</span><span class="s1">&#39;%Y-%m-%d&#39;</span><span class="p">)</span> <span class="c1">-- 4713-10-09</span> <span class="n">text</span> <span class="o">=</span> <span class="n">date</span><span class="p">:</span><span class="n">text</span><span class="p">(</span><span class="s1">&#39;%{era} %Y-%m-%d&#39;</span><span class="p">)</span> <span class="c1">-- BC 4713-10-09</span> <span class="n">text</span> <span class="o">=</span> <span class="n">date</span><span class="p">:</span><span class="n">text</span><span class="p">(</span><span class="s1">&#39;%Y-%m-%d&#160;%{era}&#39;</span><span class="p">)</span> <span class="c1">-- 4713-10-09&amp;nbsp;BC</span> <span class="n">text</span> <span class="o">=</span> <span class="n">date</span><span class="p">:</span><span class="n">text</span><span class="p">(</span><span class="s1">&#39;%Y-%m-%d&#160;%{era}&#39;</span><span class="p">,</span> <span class="s1">&#39;era=B.C.E.&#39;</span><span class="p">)</span> <span class="c1">-- 4713-10-09&amp;nbsp;B.C.E.</span> <span class="n">text</span> <span class="o">=</span> <span class="n">date</span><span class="p">:</span><span class="n">text</span><span class="p">(</span><span class="s1">&#39;%Y-%m-%d&#39;</span><span class="p">,</span> <span class="s1">&#39;era=BCNEGATIVE&#39;</span><span class="p">)</span> <span class="c1">-- -4712-10-09</span> <span class="n">text</span> <span class="o">=</span> <span class="n">date</span><span class="p">:</span><span class="n">text</span><span class="p">(</span><span class="s1">&#39;%Y-%m-%d&#39;</span><span class="p">,</span> <span class="s1">&#39;era=BCMINUS&#39;</span><span class="p">)</span> <span class="c1">-- −4712-10-09 (uses Unicode MINUS SIGN U+2212)</span> <span class="n">text</span> <span class="o">=</span> <span class="n">Date</span><span class="p">(</span><span class="s1">&#39;juliandate&#39;</span><span class="p">,</span><span class="mi">320</span><span class="p">):</span><span class="n">text</span><span class="p">(</span><span class="s1">&#39;%{gsd}&#160;%{jd}&#39;</span><span class="p">)</span> <span class="c1">-- -1721105 320</span> <span class="n">text</span> <span class="o">=</span> <span class="n">Date</span><span class="p">(</span><span class="s1">&#39;Oct 9, 4713 B.C.E.&#39;</span><span class="p">):</span><span class="n">text</span><span class="p">(</span><span class="s1">&#39;%{gsd}&#160;%{jd}&#39;</span><span class="p">)</span> <span class="c1">-- -1721105 320</span> <span class="n">text</span> <span class="o">=</span> <span class="n">Date</span><span class="p">(</span><span class="o">-</span><span class="mi">4712</span><span class="p">,</span><span class="mi">10</span><span class="p">,</span><span class="mi">9</span><span class="p">):</span><span class="n">text</span><span class="p">(</span><span class="s1">&#39;%{gsd}&#160;%{jd}&#39;</span><span class="p">)</span> <span class="c1">-- -1721105 320</span> </pre></div> <div class="mw-heading mw-heading2"><h2 id="Date_differences">Date differences</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Modiwl:Date/doc&amp;action=edit&amp;section=3" title="Edit section&#039;s source code: Date differences"><span>golygu cod</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>The difference between two dates can be determined with <code>date1 - date2</code>. The result is valid if both dates use the Gregorian calendar or if both dates use the Julian calendar, otherwise the result is nil. An age and duration can be calculated from a date difference. </p><p>For example: </p> <div class="mw-highlight mw-highlight-lang-lua mw-content-ltr" dir="ltr"><pre><span></span><span class="c1">-- Code -- Result</span> <span class="n">Date</span> <span class="o">=</span> <span class="nb">require</span><span class="p">(</span><span class="s1">&#39;Module:Date&#39;</span><span class="p">).</span><span class="n">_Date</span> <span class="n">date1</span> <span class="o">=</span> <span class="n">Date</span><span class="p">(</span><span class="s1">&#39;21 Mar 2015&#39;</span><span class="p">)</span> <span class="n">date2</span> <span class="o">=</span> <span class="n">Date</span><span class="p">(</span><span class="s1">&#39;4 Dec 1999&#39;</span><span class="p">)</span> <span class="n">diff</span> <span class="o">=</span> <span class="n">date1</span> <span class="o">-</span> <span class="n">date2</span> <span class="n">d</span> <span class="o">=</span> <span class="n">diff</span><span class="p">.</span><span class="n">age_days</span> <span class="c1">-- 5586</span> <span class="n">y</span><span class="p">,</span> <span class="n">m</span><span class="p">,</span> <span class="n">d</span> <span class="o">=</span> <span class="n">diff</span><span class="p">.</span><span class="n">years</span><span class="p">,</span> <span class="n">diff</span><span class="p">.</span><span class="n">months</span><span class="p">,</span> <span class="n">diff</span><span class="p">.</span><span class="n">days</span> <span class="c1">-- 15, 3, 17 (15 years + 3 months + 17 days)</span> <span class="n">y</span><span class="p">,</span> <span class="n">m</span><span class="p">,</span> <span class="n">d</span> <span class="o">=</span> <span class="n">diff</span><span class="p">:</span><span class="n">age</span><span class="p">(</span><span class="s1">&#39;ymd&#39;</span><span class="p">)</span> <span class="c1">-- 15, 3, 17</span> <span class="n">y</span><span class="p">,</span> <span class="n">m</span><span class="p">,</span> <span class="n">w</span><span class="p">,</span> <span class="n">d</span> <span class="o">=</span> <span class="n">diff</span><span class="p">:</span><span class="n">age</span><span class="p">(</span><span class="s1">&#39;ymwd&#39;</span><span class="p">)</span> <span class="c1">-- 15, 3, 2, 3 (15 years + 3 months + 2 weeks + 3 days)</span> <span class="n">y</span><span class="p">,</span> <span class="n">m</span><span class="p">,</span> <span class="n">w</span><span class="p">,</span> <span class="n">d</span> <span class="o">=</span> <span class="n">diff</span><span class="p">:</span><span class="n">duration</span><span class="p">(</span><span class="s1">&#39;ymwd&#39;</span><span class="p">)</span> <span class="c1">-- 15, 3, 2, 4</span> <span class="n">d</span> <span class="o">=</span> <span class="n">diff</span><span class="p">:</span><span class="n">duration</span><span class="p">(</span><span class="s1">&#39;d&#39;</span><span class="p">)</span> <span class="c1">-- 5587 (a duration includes the final day)</span> </pre></div> <p>A date difference holds the original dates except they are swapped so <code>diff.date1 &gt;= diff.date2</code> (<code>diff.date1</code> is the more recent date). This is shown in the following. </p> <div class="mw-highlight mw-highlight-lang-lua mw-content-ltr" dir="ltr"><pre><span></span><span class="n">date1</span> <span class="o">=</span> <span class="n">Date</span><span class="p">(</span><span class="s1">&#39;21 Mar 2015&#39;</span><span class="p">)</span> <span class="n">date2</span> <span class="o">=</span> <span class="n">Date</span><span class="p">(</span><span class="s1">&#39;4 Dec 1999&#39;</span><span class="p">)</span> <span class="n">diff</span> <span class="o">=</span> <span class="n">date1</span> <span class="o">-</span> <span class="n">date2</span> <span class="n">neg</span> <span class="o">=</span> <span class="n">diff</span><span class="p">.</span><span class="n">isnegative</span> <span class="c1">-- false</span> <span class="n">text</span> <span class="o">=</span> <span class="n">diff</span><span class="p">.</span><span class="n">date1</span><span class="p">:</span><span class="n">text</span><span class="p">()</span> <span class="c1">-- 21 March 2015</span> <span class="n">text</span> <span class="o">=</span> <span class="n">diff</span><span class="p">.</span><span class="n">date2</span><span class="p">:</span><span class="n">text</span><span class="p">()</span> <span class="c1">-- 4 December 1999</span> <span class="n">diff</span> <span class="o">=</span> <span class="n">date2</span> <span class="o">-</span> <span class="n">date1</span> <span class="n">neg</span> <span class="o">=</span> <span class="n">diff</span><span class="p">.</span><span class="n">isnegative</span> <span class="c1">-- true (dates have been swapped)</span> <span class="n">text</span> <span class="o">=</span> <span class="n">diff</span><span class="p">.</span><span class="n">date1</span><span class="p">:</span><span class="n">text</span><span class="p">()</span> <span class="c1">-- 21 March 2015</span> <span class="n">text</span> <span class="o">=</span> <span class="n">diff</span><span class="p">.</span><span class="n">date2</span><span class="p">:</span><span class="n">text</span><span class="p">()</span> <span class="c1">-- 4 December 1999</span> </pre></div> <p>A date difference also holds a time difference: </p> <div class="mw-highlight mw-highlight-lang-lua mw-content-ltr" dir="ltr"><pre><span></span><span class="n">date1</span> <span class="o">=</span> <span class="n">Date</span><span class="p">(</span><span class="s1">&#39;8 Mar 2016 0:30:45&#39;</span><span class="p">)</span> <span class="n">date2</span> <span class="o">=</span> <span class="n">Date</span><span class="p">(</span><span class="s1">&#39;19 Jan 2014 22:55&#39;</span><span class="p">)</span> <span class="n">diff</span> <span class="o">=</span> <span class="n">date1</span> <span class="o">-</span> <span class="n">date2</span> <span class="n">y</span><span class="p">,</span> <span class="n">m</span><span class="p">,</span> <span class="n">d</span> <span class="o">=</span> <span class="n">diff</span><span class="p">.</span><span class="n">years</span><span class="p">,</span> <span class="n">diff</span><span class="p">.</span><span class="n">months</span><span class="p">,</span> <span class="n">diff</span><span class="p">.</span><span class="n">days</span> <span class="c1">-- 2, 1, 17</span> <span class="n">H</span><span class="p">,</span> <span class="n">M</span><span class="p">,</span> <span class="n">S</span> <span class="o">=</span> <span class="n">diff</span><span class="p">.</span><span class="n">hours</span><span class="p">,</span> <span class="n">diff</span><span class="p">.</span><span class="n">minutes</span><span class="p">,</span> <span class="n">diff</span><span class="p">.</span><span class="n">seconds</span> <span class="c1">-- 1, 35, 45</span> </pre></div> <p>A date difference can be added to a date, or subtracted from a date. </p> <div class="mw-highlight mw-highlight-lang-lua mw-content-ltr" dir="ltr"><pre><span></span><span class="n">date1</span> <span class="o">=</span> <span class="n">Date</span><span class="p">(</span><span class="s1">&#39;8 Mar 2016 0:30:45&#39;</span><span class="p">)</span> <span class="n">date2</span> <span class="o">=</span> <span class="n">Date</span><span class="p">(</span><span class="s1">&#39;19 Jan 2014 22:55&#39;</span><span class="p">)</span> <span class="n">diff</span> <span class="o">=</span> <span class="n">date1</span> <span class="o">-</span> <span class="n">date2</span> <span class="n">date3</span> <span class="o">=</span> <span class="n">date2</span> <span class="o">+</span> <span class="n">diff</span> <span class="n">date4</span> <span class="o">=</span> <span class="n">date1</span> <span class="o">-</span> <span class="n">diff</span> <span class="n">text</span> <span class="o">=</span> <span class="n">date3</span><span class="p">:</span><span class="n">text</span><span class="p">(</span><span class="s1">&#39;ymd hms&#39;</span><span class="p">)</span> <span class="c1">-- 2016-03-08 00:30:45</span> <span class="n">text</span> <span class="o">=</span> <span class="n">date4</span><span class="p">:</span><span class="n">text</span><span class="p">(</span><span class="s1">&#39;ymd hms&#39;</span><span class="p">)</span> <span class="c1">-- 2014-01-19 22:55:00</span> <span class="n">equal</span> <span class="o">=</span> <span class="p">(</span><span class="n">date1</span> <span class="o">==</span> <span class="n">date3</span><span class="p">)</span> <span class="c1">-- true</span> <span class="n">equal</span> <span class="o">=</span> <span class="p">(</span><span class="n">date2</span> <span class="o">==</span> <span class="n">date4</span><span class="p">)</span> <span class="c1">-- true</span> </pre></div> <p>The age and duration methods of a date difference accept a code that identifies the components that should be returned. An extra day is included for the duration method because it includes the final day. </p> <table class="wikitable"> <tbody><tr> <th>Code</th> <th>Returned values </th></tr> <tr> <td><code>'ymwd'</code></td> <td>years, months, weeks, days </td></tr> <tr> <td><code>'ymd'</code></td> <td>years, months, days </td></tr> <tr> <td><code>'ym'</code></td> <td>years, months </td></tr> <tr> <td><code>'y'</code></td> <td>years </td></tr> <tr> <td><code>'m'</code></td> <td>months </td></tr> <tr> <td><code>'wd'</code></td> <td>weeks, days </td></tr> <tr> <td><code>'w'</code></td> <td>weeks </td></tr> <tr> <td><code>'d'</code></td> <td>days </td></tr></tbody></table> <!-- NewPP limit report Parsed by mw‐web.codfw.main‐5c59558b9d‐qd9kp Cached time: 20241201155801 Cache expiry: 2592000 Reduced expiry: false Complications: [] CPU time usage: 0.027 seconds Real time usage: 0.030 seconds Preprocessor visited node count: 40/1000000 Post‐expand include size: 0/2097152 bytes Template argument size: 0/2097152 bytes Highest expansion depth: 2/100 Expensive parser function count: 6/500 Unstrip recursion depth: 0/20 Unstrip post‐expand size: 15265/5000000 bytes Number of Wikibase entities loaded: 0/400 --> <!-- Transclusion expansion time report (%,ms,calls,template) 100.00% 0.000 1 -total --> <!-- Saved in parser cache with key cywiki:pcache:287340:|#|:idhash:canonical and timestamp 20241201155801 and revision id 10910305. Rendering was triggered because: page-view --> </div><!--esi <esi:include src="/esitest-fa8a495983347898/content" /> --><noscript><img src="https://login.wikimedia.org/wiki/Special:CentralAutoLogin/start?type=1x1&amp;useformat=desktop" alt="" width="1" height="1" style="border: none; position: absolute;"></noscript> <div class="printfooter" data-nosnippet="">Wedi dod o "<a dir="ltr" href="https://cy.wikipedia.org/w/index.php?title=Modiwl:Date/doc&amp;oldid=10910305">https://cy.wikipedia.org/w/index.php?title=Modiwl:Date/doc&amp;oldid=10910305</a>"</div></div> <div id="catlinks" class="catlinks catlinks-allhidden" data-mw="interface"></div> </div> </main> </div> <div class="mw-footer-container"> <footer id="footer" class="mw-footer" > <ul id="footer-info"> <li id="footer-info-lastmod"> Golygwyd y dudalen hon ddiwethaf ar 31 Mawrth 2021, am 06:26.</li> <li id="footer-info-copyright">Mae'r testun ar gael o dan <a rel="nofollow" class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">Creative Commons Attribution-ShareAlike License</a>; gall telerau ychwanegol fod yn berthnasol. Gweler y <a class="external text" href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Terms_of_Use">Telerau Gwasanaeth</a> am fanylion.</li> </ul> <ul id="footer-places"> <li id="footer-places-privacy"><a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Privacy_policy">Polisi preifatrwydd</a></li> <li id="footer-places-about"><a href="/wiki/Wicipedia:Yngl%C5%B7n_%C3%A2_Wicipedia">Ynglŷn â Wicipedia</a></li> <li id="footer-places-disclaimers"><a href="/wiki/Wicipedia:Gwadiad_Cyffredinol">Gwadiadau</a></li> <li id="footer-places-wm-codeofconduct"><a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Universal_Code_of_Conduct">Cod Ymddygiad</a></li> <li id="footer-places-developers"><a href="https://developer.wikimedia.org">Datblygwyr</a></li> <li id="footer-places-statslink"><a href="https://stats.wikimedia.org/#/cy.wikipedia.org">Ystadegau</a></li> <li id="footer-places-cookiestatement"><a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Cookie_statement">Datganiad cwcis</a></li> <li id="footer-places-mobileview"><a href="//cy.m.wikipedia.org/w/index.php?title=Modiwl:Date/doc&amp;mobileaction=toggle_view_mobile" class="noprint stopMobileRedirectToggle">Golwg symudol</a></li> </ul> <ul id="footer-icons" class="noprint"> <li id="footer-copyrightico"><a href="https://wikimediafoundation.org/" class="cdx-button cdx-button--fake-button cdx-button--size-large cdx-button--fake-button--enabled"><img src="/static/images/footer/wikimedia-button.svg" width="84" height="29" alt="Wikimedia Foundation" loading="lazy"></a></li> <li id="footer-poweredbyico"><a href="https://www.mediawiki.org/" class="cdx-button cdx-button--fake-button cdx-button--size-large cdx-button--fake-button--enabled"><img src="/w/resources/assets/poweredby_mediawiki.svg" alt="Powered by MediaWiki" width="88" height="31" loading="lazy"></a></li> </ul> </footer> </div> </div> </div> <div class="vector-settings" id="p-dock-bottom"> <ul></ul> </div><script>(RLQ=window.RLQ||[]).push(function(){mw.config.set({"wgHostname":"mw-web.codfw.main-5c59558b9d-qd9kp","wgBackendResponseTime":167,"wgPageParseReport":{"limitreport":{"cputime":"0.027","walltime":"0.030","ppvisitednodes":{"value":40,"limit":1000000},"postexpandincludesize":{"value":0,"limit":2097152},"templateargumentsize":{"value":0,"limit":2097152},"expansiondepth":{"value":2,"limit":100},"expensivefunctioncount":{"value":6,"limit":500},"unstrip-depth":{"value":0,"limit":20},"unstrip-size":{"value":15265,"limit":5000000},"entityaccesscount":{"value":0,"limit":400},"timingprofile":["100.00% 0.000 1 -total"]},"cachereport":{"origin":"mw-web.codfw.main-5c59558b9d-qd9kp","timestamp":"20241201155801","ttl":2592000,"transientcontent":false}}});});</script> </body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10