Date format: Difference between revisions

15,095 bytes added ,  17 days ago
m (→‎{{header|Phix}}: added personal tag)
 
(30 intermediate revisions by 18 users not shown)
Line 9:
 
=={{header|11l}}==
<langsyntaxhighlight lang="11l">print(Time().format(‘YYYY-MM-DD’))
print(Time().strftime(‘%A, %B %e, %Y’))</langsyntaxhighlight>
 
=={{header|68000 Assembly}}==
{{works with|NEOGEO MVS}}
This code only works on the arcade system, not the home consoles, because only the arcade system has a built-in system clock. which can be read using <code>JSR $C0045C</code>. MAME uses your computer's date and time as the source for this data. The code below runs in-line and uses a few macros and labels, but they are mostly self-explanatory. The code required to set up the palettes and print characters to the screen has been omitted for brevity, but is fully implemented.
 
<syntaxhighlight lang="68000devpac"> JSR SYS_READ_CALENDAR ;outputs calendar date to BIOS RAM
 
MOVE.B #'2',D0 ;a character in single or double quotes refers to its ascii equivalent.
JSR PrintChar
MOVE.B #'0',D0
JSR PrintChar
LEA BIOS_YEAR,A1
MOVE.B (A1)+,D0 ;stores last 2 digits of year into D0, in binary coded decimal
JSR UnpackNibbles8 ;separate the digits into high and low nibbles: D0 = 00020001
ADD.L #$00300030,D0 ;convert both numerals to their ascii equivalents.
SWAP D0 ;print the "2" first
JSR PrintChar
SWAP D0 ;then the "1"
JSR PrintChar
MOVE.B #'-',D0
JSR PrintChar
MOVE.B (A1)+,D0 ;get the month
JSR UnpackNibbles8
ADD.L #$00300030,D0
SWAP D0
JSR PrintChar
SWAP D0
JSR PrintChar
MOVE.B #'-',D0
JSR PrintChar
MOVE.B (A1)+,D0 ;get the day
JSR UnpackNibbles8
ADD.L #$00300030,D0
SWAP D0
JSR PrintChar
SWAP D0
JSR PrintChar
;now the date is printed.
;Now do it again only written out:
jsr NewLine
CLR.L D0 ;reset D0
MOVE.B (A1),D0 ;A1 happens to point to the weekday
LSL.W #2,D0 ;we are indexing into a table of longs
LEA Days_Lookup,A2
LEA (A2,D0),A2
MOVEA.L (A2),A3 ;dereference the pointer into A3, which the PrintString routine takes as an argument.
JSR PrintString
CLR.L D0
LEA BIOS_MONTH,A1 ;GET THE MONTH
MOVE.B (A1)+,D0
LSL.W #2,D0
LEA Months_Lookup,A2
LEA (A2,D0),A2
MOVEA.L (A2),A3
JSR PrintString
MOVE.B (A1),D0 ;GET THE DAY
JSR UnpackNibbles8
ADD.L #$00300030,D0
SWAP D0
JSR PrintChar
SWAP D0
JSR PrintChar
MOVE.B #',',D0
JSR PrintChar
MOVE.B #' ',D0
JSR PrintChar
MOVE.B #'2',D0
JSR PrintChar
MOVE.B #'0',D0
JSR PrintChar
LEA BIOS_YEAR,A1
MOVE.B (A1)+,D0 ;stores last 2 digits of year into D0, in binary coded decimal
JSR UnpackNibbles8 ;separate the digits into high and low nibbles: D0 = 00020001
ADD.L #$00300030,D0 ;convert both numerals to their ascii equivalents.
SWAP D0 ;print the "2" first
JSR PrintChar
SWAP D0 ;then the "1"
JSR PrintChar
 
forever:
bra forever ;trap the program counter
 
UnpackNibbles8:
; INPUT: D0 = THE VALUE YOU WISH TO UNPACK.
; HIGH NIBBLE IN HIGH WORD OF D0, LOW NIBBLE IN LOW WORD. SWAP D0 TO GET THE OTHER HALF.
pushWord D1
CLR.W D1
MOVE.B D0,D1
CLR.L D0
MOVE.B D1,D0 ;now D0 = D1 = $000000II, where I = input
AND.B #$F0,D0 ;chop off bottom nibble
LSR.B #4,D0 ;downshift top nibble into bottom nibble of the word
SWAP D0 ;store in high word
AND.B #$0F,D1 ;chop off bottom nibble
MOVE.B D1,D0 ;store in low word
popWord D1
rts</syntaxhighlight>
 
Output can be seen [https://ibb.co/52Ks0yf here,] but is also reproduced below:
<pre>
2021-09-19
Sunday, September 19, 2021
</pre>
 
=={{header|8th}}==
<langsyntaxhighlight lang="forth">
d:new
"%Y-%M-%D" over d:format . cr
"%W, %N %D, %Y" over d:format . cr
bye
</syntaxhighlight>
</lang>
 
=={{header|AArch64 Assembly}}==
{{works with|as|Raspberry Pi 3B version Buster 64 bits}}
<syntaxhighlight lang="aarch64 assembly">
<lang AArch64 Assembly>
/* ARM assembly AARCH64 Raspberry PI 3B */
/* program dateFormat64.s */
Line 342 ⟶ 463:
/* for this file see task include a file in language AArch64 assembly */
.include "../includeARM64.inc"
</syntaxhighlight>
</lang>
=={{header|ABAP}}==
<syntaxhighlight lang="abap">
<lang ABAP>
report zdate.
data: lv_month type string,
Line 366 ⟶ 487:
concatenate sy-datum(4) '-' sy-datum+4(2) '-' sy-datum+6(2) into lv_date.
write / lv_date.
</syntaxhighlight>
</lang>
 
=={{header|Action!}}==
<syntaxhighlight lang="action!">DEFINE PTR="CARD"
 
TYPE Date=[
INT year
BYTE month
BYTE day]
 
PTR ARRAY DayOfWeeks(7)
PTR ARRAY Months(12)
 
PROC Init()
DayOfWeeks(0)="Sunday" DayOfWeeks(1)="Monday"
DayOfWeeks(2)="Tuesday" DayOfWeeks(3)="Wednesday"
DayOfWeeks(4)="Thursday" DayOfWeeks(5)="Friday"
DayOfWeeks(6)="Saturday"
Months(0)="January" Months(1)="February"
Months(2)="March" Months(3)="April"
Months(4)="May" Months(5)="June"
Months(6)="July" Months(7)="August"
Months(8)="September" Months(9)="October"
Months(10)="November" Months(11)="December"
RETURN
 
;https://en.wikipedia.org/wiki/Determination_of_the_day_of_the_week#Sakamoto.27s_methods
BYTE FUNC DayOfWeek(Date POINTER d) ;1<=m<=12, y>1752
BYTE ARRAY t=[0 3 2 5 0 3 5 1 4 6 2 4]
BYTE res
INT y
 
y=d.year
IF d.month<3 THEN
y==-1
FI
res=(y+y/4-y/100+y/400+t(d.month-1)+d.day) MOD 7
RETURN (res)
 
PROC PrintB2(BYTE x)
IF x<10 THEN
Put('0)
FI
PrintB(x)
RETURN
 
PROC PrintDateShort(Date POINTER d)
PrintI(d.year) Put('-)
PrintB2(d.month) Put('-)
PrintB2(d.day)
RETURN
 
PROC PrintDateLong(Date POINTER d)
BYTE wd
 
wd=DayOfWeek(d)
Print(DayOfWeeks(wd)) Print(", ")
Print(Months(d.month-1)) Put(' )
PrintB(d.day) Print(", ")
PrintI(d.year)
RETURN
 
PROC Main()
Date d
 
Init()
 
;There is no function to get the current date
;on Atari 8-bit computer
d.year=2021 d.month=9 d.day=1
 
PrintDateShort(d) PutE()
PrintDateLong(d) PutE()
RETURN</syntaxhighlight>
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Date_format.png Screenshot from Atari 8-bit computer]
<pre>
2021-09-01
Wednesday, September 1, 2021
</pre>
 
=={{header|Ada}}==
<langsyntaxhighlight lang="ada">with Ada.Calendar; use Ada.Calendar;
with Ada.Calendar.Formatting; use Ada.Calendar.Formatting;
with Ada.Text_IO; use Ada.Text_IO;
Line 412 ⟶ 612:
& Year_Number'Image (Ada.Calendar.Year (Today))
);
end Date_Format;</langsyntaxhighlight>
 
{{out}}
Line 425 ⟶ 625:
Note: the '''format''' can be used for both printing ''and'' reading date data.
 
<langsyntaxhighlight lang="algol68"># define the layout of the date/time as provided by the call to local time #
STRUCT ( INT sec, min, hour, mday, mon, year, wday, yday, isdst) tm = (6,5,4,3,2,1,7,~,8);
 
Line 447 ⟶ 647:
 
printf((unix time repr, now[wday OF tm], now[mon OF tm], now[mday OF tm],
now[hour OF tm:sec OF tm], now[isdst OF tm]+1, now[year OF tm], $l$))</langsyntaxhighlight>
{{out}}
<pre>
Line 456 ⟶ 656:
 
=={{header|Apex}}==
<langsyntaxhighlight lang="java">
Datetime dtNow = datetime.now();
String strDt1 = dtNow.format('yyyy-MM-dd');
Line 462 ⟶ 662:
system.debug(strDt1); // "2007-11-10"
system.debug(strDt2); //"Sunday, November 10, 2007"
</syntaxhighlight>
</lang>
 
{{out}}
Line 477 ⟶ 677:
Whether or not they happen to work, to insist on posting code containing things which have never been part of the language without noting them as hacks, when they're entirely unnecessary, and deleting legitimate and effective code to make way for them, is seriously to misinform readers.
 
<langsyntaxhighlight lang="applescript">set {year:y, month:m, day:d, weekday:w} to (current date)
 
tell (y * 10000 + m * 100 + d) as text to set shortFormat to text 1 thru 4 & "-" & text 5 thru 6 & "-" & text 7 thru 8
set longFormat to (w as text) & (", " & m) & (space & d) & (", " & y)
 
return (shortFormat & linefeed & longFormat)</langsyntaxhighlight>
 
{{output}}
 
<langsyntaxhighlight lang="applescript">"2020-10-28
Wednesday, October 28, 2020"</langsyntaxhighlight>
 
===Hack alternative===
Line 502 ⟶ 702:
 
 
<langsyntaxhighlight lang="applescript">tell (the current date)
set shortdate to text 1 thru 10 of (it as «class isot» as string)
set longdate to the contents of [its weekday, ", ", ¬
Line 509 ⟶ 709:
 
log the shortdate
log the longdate</langsyntaxhighlight>
 
{{output}}
Line 518 ⟶ 718:
Or, emphasising productivity and functional composition:
 
<langsyntaxhighlight lang="applescript">-- iso8601Short :: Date -> String
on iso8601Short(dte)
text 1 thru 10 of iso8601Local(dte)
Line 588 ⟶ 788:
set my text item delimiters to dlm
s
end unlines</langsyntaxhighlight>
{{Out}}
<pre>2020-09-11
Line 595 ⟶ 795:
=={{header|ARM Assembly}}==
{{works with|as|Raspberry Pi}}
<syntaxhighlight lang="arm assembly">
<lang ARM Assembly>
/* ARM assembly Raspberry PI */
/* program dateFormat.s */
Line 943 ⟶ 1,143:
/***************************************************/
.include "../affichage.inc"
</syntaxhighlight>
</lang>
{{Output}}
<pre>
Line 958 ⟶ 1,158:
=={{header|Arturo}}==
 
<langsyntaxhighlight lang="rebol">currentTime: now
 
print to :string.format: "YYYY-MM-dd" currentTime
print to :string.format: "dddd, MMMM dd, YYYY" currentTime</langsyntaxhighlight>
 
{{out}}
Line 969 ⟶ 1,169:
 
=={{header|AutoHotkey}}==
<langsyntaxhighlight lang="autohotkey">FormatTime, Date1, , yyyy-MM-dd ; "2007-11-10"
FormatTime, Date2, , LongDate ; "Sunday, November 10, 2007"
MsgBox %Date1% `n %Date2%</langsyntaxhighlight>
 
=={{header|AutoIt}}==
This solution uses the locale settings for names of days and months.
<syntaxhighlight lang="autoit">
<lang AutoIt>
#include <Date.au3>
 
Line 1,007 ⟶ 1,207:
Return $ret[3]
EndFunc
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 1,017 ⟶ 1,217:
=={{header|AWK}}==
{{works with|Gawk}}
<langsyntaxhighlight lang="awk">$ awk 'BEGIN{t=systime();print strftime("%Y-%m-%d",t)"\n"strftime("%A, %B %d, %Y",t)}'
2009-05-15
Friday, May 15, 2009</langsyntaxhighlight>
 
=={{header|BaCon}}==
<langsyntaxhighlight lang="freebasic">' Date format
n = NOW
PRINT YEAR(n), MONTH(n), DAY(n) FORMAT "%ld-%02ld-%02ld\n"
PRINT WEEKDAY$(n), MONTH$(n), DAY(n), YEAR(n) FORMAT "%s, %s %02ld, %ld\n"</langsyntaxhighlight>
 
{{out}}
Line 1,034 ⟶ 1,234:
=={{header|BASIC}}==
{{works with|FreeBASIC}}
<langsyntaxhighlight lang="freebasic">#include "vbcompat.bi"
 
DIM today As Double = Now()
 
PRINT Format(today, "yyyy-mm-dd")
PRINT Format(today, "dddd, mmmm d, yyyy")</langsyntaxhighlight>
 
=={{header|Batch File}}==
<langsyntaxhighlight lang="dos">
@echo off
setlocal enabledelayedexpansion
Line 1,078 ⟶ 1,278:
echo %fulldayname%, %monthname% %day%, %year%
pause>nul
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 1,086 ⟶ 1,286:
 
=={{header|BBC BASIC}}==
<langsyntaxhighlight lang="bbcbasic"> daysow$ = "Sunday Monday Tuesday Wednesday Thursday Friday Saturday"
months$ = "January February March April May June " + \
\ "July August September October November December"
Line 1,103 ⟶ 1,303:
DEF FNrtrim(A$)
WHILE RIGHT$(A$) = " " A$ = LEFT$(A$) : ENDWHILE
= A$</langsyntaxhighlight>
 
=={{header|Beads}}==
Line 1,133 ⟶ 1,333:
// [iso time] = [hour]:[minute]:[second], e.g. 18:06:05
</pre>
<langsyntaxhighlight lang="beads">beads 1 program 'Date format'
 
calc main_init
log time_to_str('[iso date]')
log time_to_str('[sunday], [january] [day2], [year]')</langsyntaxhighlight>
 
{{out}}
Line 1,146 ⟶ 1,346:
=={{header|C}}==
<langsyntaxhighlight lang="c">#include <stdlib.h>
#include <stdio.h>
#include <time.h>
Line 1,168 ⟶ 1,368:
(void) printf("%s\n", buf);
return EXIT_SUCCESS;
}</langsyntaxhighlight>
{{out}}
<pre>
Line 1,176 ⟶ 1,376:
 
=={{header|C sharp|C#}}==
<langsyntaxhighlight lang="csharp">using System;
 
namespace RosettaCode.DateFormat
Line 1,189 ⟶ 1,389:
}
}
}</langsyntaxhighlight>
 
=={{header|C++}}==
<langsyntaxhighlight lang="cpp">// Display the current date in the formats of "2007-11-10"
// and "Sunday, November 10, 2007".
 
Line 1,255 ⟶ 1,455:
std::cout << d.getTextDate() << std::endl;
return 0;
}</langsyntaxhighlight>
{{out}}
<pre>
Line 1,263 ⟶ 1,463:
 
=={{header|Clojure}}==
<langsyntaxhighlight lang="lisp">(let [now (.getTime (java.util.Calendar/getInstance))
f1 (java.text.SimpleDateFormat. "yyyy-MM-dd")
f2 (java.text.SimpleDateFormat. "EEEE, MMMM dd, yyyy")]
(println (.format f1 now))
(println (.format f2 now)))</langsyntaxhighlight>
 
{{out}}
Line 1,275 ⟶ 1,475:
=={{header|COBOL}}==
{{works with|OpenCOBOL}}
<langsyntaxhighlight lang="cobol"> IDENTIFICATION DIVISION.
PROGRAM-ID. Date-Format.
 
Line 1,338 ⟶ 1,538:
 
GOBACK
.</langsyntaxhighlight>
 
=={{header|CoffeeScript}}==
=== ECMAScript ≥ 5.1 ===
Is supported by at least: Chrome 24, Firefox/Gecko 29, IE 11, Opera 15, and Node.js (at least as of 2015).
<langsyntaxhighlight lang="coffeescript">
date = new Date
 
Line 1,357 ⟶ 1,557:
day: 'numeric'
year: 'numeric'
</syntaxhighlight>
</lang>
 
=== Portable version ===
<langsyntaxhighlight lang="coffeescript">
# JS does not have extensive formatting support out of the box. This code shows
# how you could create a date formatter object.
Line 1,387 ⟶ 1,587:
console.log formatter.brief(date)
console.log formatter.verbose(date)
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 1,396 ⟶ 1,596:
 
=={{header|ColdFusion}}==
<langsyntaxhighlight lang="cfm"><cfoutput>
#dateFormat(Now(), "YYYY-MM-DD")#<br />
#dateFormat(Now(), "DDDD, MMMM DD, YYYY")#
</cfoutput></langsyntaxhighlight>
 
=={{header|Common Lisp}}==
<langsyntaxhighlight lang="lisp">(defconstant *day-names*
#("Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday" "Sunday"))
(defconstant *month-names*
Line 1,411 ⟶ 1,611:
(format t "~4d-~2,'0d-~2,'0d~%" year month date)
(format t "~a, ~a ~d, ~4d~%"
(aref *day-names* day) (aref *month-names* month) date year))</langsyntaxhighlight>
 
With the local-time library:
 
<langsyntaxhighlight lang="lisp">
(local-time:format-timestring nil (local-time:now) :format '(:year "-" (:month 2) "-" (:day 2)))
;; => "2019-11-13"
(local-time:format-timestring nil (local-time:now) :format '(:long-weekday ", " :long-month #\space (:day 2) ", " :year))
;; => "Wednesday, November 13, 2019"
</syntaxhighlight>
</lang>
 
=={{header|Component Pascal}}==
BlackBox Component Builder
<langsyntaxhighlight lang="oberon2">
MODULE DateFormat;
IMPORT StdLog, Dates;
Line 1,446 ⟶ 1,646:
END Do;
END DateFormat.
</syntaxhighlight>
</lang>
Execute: ^Q DateFormat.Do<br/>
{{out}}
Line 1,460 ⟶ 1,660:
=={{header|Crystal}}==
{{works with|Crystal|0.33}}
<langsyntaxhighlight lang="crystal">require "time"
 
time = Time.local
puts time.to_s("%Y-%m-%d")
puts time.to_s("%A, %B %d, %Y")
</syntaxhighlight>
</lang>
 
=={{header|D}}==
{{works with|D|DMD 1.026}}
{{libheader|Tango}}
<langsyntaxhighlight lang="d">module datetimedemo ;
 
import tango.time.Time ;
Line 1,486 ⟶ 1,686:
d = g.toTime(2008, 2, 1, 0, 0, 0, 0, g.AD_ERA) ;
Stdout.format("{:dddd, MMMM d, yyy}", d).newline ;
}</langsyntaxhighlight>
{{out}}
<pre>2007-11-10
Line 1,493 ⟶ 1,693:
 
=={{header|Delphi}}==
<langsyntaxhighlight Delphilang="delphi">ShowMessage(FormatDateTime('yyyy-mm-dd', Now) +#13#10+ FormatDateTime('dddd, mmmm dd, yyyy', Now));</langsyntaxhighlight>
{{out}}
<pre>
2022-02-16
Wednesday, February 16, 2022
Redirecting to
</pre>
 
=={{header|Diego}}==
<syntaxhighlight lang="diego">me_lang(en)_cal(gregorian);
me_msg()_now()_format(yyyy-mm-dd);
me_msg()_now()_format(eeee, mmmm dd, yyyy);</syntaxhighlight>
 
=={{header|EGL}}==
<syntaxhighlight lang="egl">
<lang EGL>
// 2012-09-26
SysLib.writeStdout(StrLib.formatDate(DateTimeLib.currentDate(), "yyyy-MM-dd"));
Line 1,502 ⟶ 1,713:
SysLib.setLocale("en", "US");
SysLib.writeStdout(StrLib.formatDate(DateTimeLib.currentDate(), "EEEE, MMMM dd, yyyy"));
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 1,512 ⟶ 1,723:
{{trans|Erlang}}
{{works with|Elixir|1.4}}
<langsyntaxhighlight lang="elixir">defmodule Date_format do
def iso_date, do: Date.utc_today |> Date.to_iso8601
Line 1,534 ⟶ 1,745:
IO.puts Date_format.long_date
IO.puts Date_format.iso_date(2007,11,10)
IO.puts Date_format.long_date(2007,11,10)</langsyntaxhighlight>
 
{{out}}
Line 1,545 ⟶ 1,756:
 
=={{header|Emacs Lisp}}==
<langsyntaxhighlight Lisplang="lisp">(format-time-string "%Y-%m-%d")
(format-time-string "%F") ;; new in Emacs 24
;; => "2015-11-08"
 
(format-time-string "%A, %B %e, %Y")
;; => "Sunday, November 8, 2015"</syntaxhighlight>
</lang>
 
<code>%e</code> is blank-padded day number, or <code>%d</code> for zero-padded. Month and weekday names follow the current locale. On a POSIX style system this is the usual <code>LC_TIME</code> or <code>LC_ALL</code> environment variables. GNU Emacs variable <code>system-time-locale</code> can override this if desired.
Line 1,557 ⟶ 1,767:
=={{header|Erlang}}==
 
<langsyntaxhighlight Erlanglang="erlang">-module(format_date).
-export([iso_date/0, iso_date/1, iso_date/3, long_date/0, long_date/1, long_date/3]).
-import(calendar,[day_of_the_week/1]).
Line 1,580 ⟶ 1,790:
MonthName = element(Month, Months),
append([WeekdayName, ", ", MonthName, " ", integer_to_list(Day), ", ",
integer_to_list(Year)]).</langsyntaxhighlight>
 
=={{header|Euphoria}}==
<langsyntaxhighlight Euphorialang="euphoria">constant days = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"}
constant months = {"January","February","March","April","May","June",
"July","August","September","October","November","December"}
Line 1,593 ⟶ 1,803:
 
printf(1,"%d-%02d-%02d\n",now[1..3])
printf(1,"%s, %s %d, %d\n",{days[now[7]],months[now[2]],now[3],now[1]})</langsyntaxhighlight>
 
=={{header|F_Sharp|F#}}==
"F# Interactive" session:
<langsyntaxhighlight lang="fsharp">> open System;;
> Console.WriteLine( DateTime.Now.ToString("yyyy-MM-dd") );;
2010-08-13
> Console.WriteLine( "{0:D}", DateTime.Now );;
Friday, August 13, 2010</langsyntaxhighlight>
 
=={{header|Factor}}==
<langsyntaxhighlight lang="factor">USING: formatting calendar io ;
 
now "%Y-%m-%d" strftime print
now "%A, %B %d, %Y" strftime print</langsyntaxhighlight>
 
=={{header|Fantom}}==
Line 1,613 ⟶ 1,823:
Today's date can be retrieved using 'Date.today'. The 'toLocale' method can be passed formatting information to determine how the date should be represented as a string. The rules are described at http://fantom.org/doc/sys/Date.html#toLocale
 
<langsyntaxhighlight lang="fantom">
fansh> Date.today.toLocale("YYYY-MM-DD")
2011-02-24
fansh> Date.today.toLocale("WWWW, MMMM DD, YYYY")
Thursday, February 24, 2011
</syntaxhighlight>
</lang>
 
=={{header|Forth}}==
<langsyntaxhighlight lang="forth">: .-0 ( n -- n )
[char] - emit
dup 10 < if [char] 0 emit then ;
Line 1,675 ⟶ 1,885:
3dup weekday weekdays type ." , "
>R 1- months type space 1 u.r ." , " R> .
drop drop drop ;</langsyntaxhighlight>
 
=== Version 2: Meta Language ===
Forth is less of a language and more of an extensible toolkit of simple routines. This version attempts to demonstrate using the simple routines to extend Forth. Then using the language extensions and the power of concatenative language to solve the problem. This solution could create numerous date formats as one line definitions now that we have our "date" words defined. Typically these extensions would be saved as a library file.
 
<LANGsyntaxhighlight FORTHlang="forth">\ Build up a "language" for date formatting
 
\ utility words
Line 1,740 ⟶ 1,950:
\ Rosetta Date Format 2
: LONG.DATE ( d m y -- )
3DUP CDAY DOW ]DAY$. ',' -ROT ]MONTH$. SPACE ##. ',' ####. ;</LANGsyntaxhighlight>
 
 
 
Test at the Forth Console
<LANGsyntaxhighlight FORTHlang="forth"> 5 7 2018 Y-M-D. 2018-07-05 ok
ok
5 7 2018 LONG.DATE Thursday, July 05, 2018 ok
</syntaxhighlight>
</LANG>
 
=={{header|Fortran}}==
{{works with|Fortran|95 and later}}
The subroutine DATE_AND_TIME does not return day of week information so we have to write our own function for that
<langsyntaxhighlight lang="fortran">PROGRAM DATE
 
IMPLICIT NONE
Line 1,820 ⟶ 2,031:
END FUNCTION Day_of_week
 
END PROGRAM DATE</langsyntaxhighlight>
{{out}}
2008-12-14
Line 1,826 ⟶ 2,037:
 
=={{header|FreeBASIC}}==
<langsyntaxhighlight lang="freebasic">' FB 1.05.0 Win64
 
#Include "vbcompat.bi"
Line 1,835 ⟶ 2,046:
Print
Print "Press any key to quit the program"
Sleep</langsyntaxhighlight>
 
{{out}}
Line 1,841 ⟶ 2,052:
This example was created on : 2016-10-02
In other words on : Sunday, October 2, 2016
</pre>
 
=={{header|Free Pascal}}==
<syntaxhighlight lang="pascal">program Format_Date_Time;
uses
SysUtils;
begin
WriteLn(FormatDateTime('yyyy-mm-dd', Now) +#13#10+ FormatDateTime('dddd, mmmm dd, yyyy', Now));
end.
</syntaxhighlight>
{{out}}
<pre>
2022-02-16
Wednesday, February 16, 2022
</pre>
 
=={{header|Frink}}==
<langsyntaxhighlight lang="frink">
println[now[] -> ### yyyy-MM-dd ###]
println[now[] -> ### EEEE, MMMM d, yyyy ###]
</syntaxhighlight>
</lang>
 
=={{header|FunL}}==
<langsyntaxhighlight lang="funl">println( format('%tF', $date) )
println( format('%1$tA, %1$tB %1$td, %1$tY', $date) )</langsyntaxhighlight>
 
=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">window 1
 
print date(@"yyyy-MM-dd")
print date(@"EEEE, MMMM dd, yyyy")
 
HandleEvents</syntaxhighlight>
 
=={{header|Gambas}}==
'''[https://gambas-playground.proko.eu/ You can run this code. Copy the code, click this link, paste it in and press 'Run !']'''
<langsyntaxhighlight lang="gambas">Public Sub Main()
 
Print Format(Now, "yyyy - mm - dd")
Print Format(Now, "dddd, mmmm dd, yyyy")
 
End</langsyntaxhighlight>
Output:
<pre>
Line 1,869 ⟶ 2,102:
=={{header|Go}}==
In an interesting design, you specify your format by providing the format for the date and time 01/02 03:04:05PM '06 -0700
<langsyntaxhighlight lang="go">package main
 
import "time"
Line 1,877 ⟶ 2,110:
fmt.Println(time.Now().Format("2006-01-02"))
fmt.Println(time.Now().Format("Monday, January 2, 2006"))
}</langsyntaxhighlight>
{{out}}
<pre>
Line 1,886 ⟶ 2,119:
=={{header|Groovy}}==
Solution:
<langsyntaxhighlight lang="groovy">def isoFormat = { date -> date.format("yyyy-MM-dd") }
def longFormat = { date -> date.format("EEEE, MMMM dd, yyyy") }</langsyntaxhighlight>
 
Test Program:
<langsyntaxhighlight lang="groovy">def now = new Date()
println isoFormat(now)
println longFormat(now)</langsyntaxhighlight>
 
=={{header|Haskell}}==
<langsyntaxhighlight lang="haskell">import Data.Time
(FormatTime, formatTime, defaultTimeLocale, utcToLocalTime,
getCurrentTimeZone, getCurrentTime)
Line 1,905 ⟶ 2,138:
main = do
t <- pure utcToLocalTime <*> getCurrentTimeZone <*> getCurrentTime
putStrLn $ unlines (formats <*> pure t)</langsyntaxhighlight>
'''Sample output:'''
<pre>2017-06-05
Line 1,911 ⟶ 2,144:
 
=={{header|HicEst}}==
<langsyntaxhighlight lang="hicest"> CHARACTER string*40
 
WRITE(Text=string, Format='UCCYY-MM-DD') 0 ! string: 2010-03-13
Line 1,923 ⟶ 2,156:
EDIT(Text=string, Right=' ', Mark1, Right=';', Right=3, Mark2, Delete, Insert=', '//cMonth, Right=';', RePLaceby=',')
 
END</langsyntaxhighlight>
 
=={{header|Icon}} and {{header|Unicon}}==
<langsyntaxhighlight Iconlang="icon">procedure main()
write(map(&date,"/","-"))
write(&dateline ? tab(find(&date[1:5])+4))
end</langsyntaxhighlight>
 
{{out}}
Line 1,937 ⟶ 2,170:
=={{header|J}}==
Short format using built in formatting:
<langsyntaxhighlight lang="j"> 6!:0 'YYYY-MM-DD'
2010-08-19</langsyntaxhighlight>
 
Verb to show custom format:
<langsyntaxhighlight lang="j">require 'dates system/packages/misc/datefmt.ijs'
days=:;:'Sunday Monday Tuesday Wednesday Thursday Friday Saturday'
fmtDate=: [:((days ;@{~ weekday),', ',ms0) 3 {.]
 
fmtDate 6!:0 ''
Thursday, August 19, 2010</langsyntaxhighlight>
 
=={{header|Java}}==
<langsyntaxhighlight lang="java">
public static void main(String[] args) {
long millis = System.currentTimeMillis();
System.out.printf("%tF%n", millis);
System.out.printf("%tA, %1$tB %1$td, %1$tY%n", millis);
}
</syntaxhighlight>
<pre>
2023-05-10
Wednesday, May 10, 2023
</pre>
<br />
An alternate demonstration
<syntaxhighlight lang="java">
import java.util.Calendar;
import java.util.GregorianCalendar;
Line 1,968 ⟶ 2,214:
}
}
</syntaxhighlight>
</lang>
Better: use a library, see http://sourceforge.net/apps/mediawiki/threeten/index.php?title=ThreeTen
 
===Java 8 Date Time API===
<langsyntaxhighlight lang="java">
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
Line 1,986 ⟶ 2,232:
}
}
</syntaxhighlight>
</lang>
 
===Java Util Date API===
<langsyntaxhighlight lang="java">
import java.text.SimpleDateFormat;
import java.util.Date;
Line 2,001 ⟶ 2,247:
}
}
</syntaxhighlight>
</lang>
 
=={{header|JavaScript}}==
JavaScript does not have any built-in <code>strftime</code>-type functionality.
<langsyntaxhighlight lang="javascript">var now = new Date(),
weekdays = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
Line 2,011 ⟶ 2,257:
fmt2 = weekdays[now.getDay()] + ', ' + months[now.getMonth()] + ' ' + now.getDate() + ', ' + now.getFullYear();
console.log(fmt1);
console.log(fmt2);</langsyntaxhighlight>
<pre>2010-1-12
Tuesday, January 12, 2010</pre>
 
=={{header|Joy}}==
<syntaxhighlight lang="joy">
<lang Joy>
DEFINE weekdays == [ "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday" "Sunday" ];
months == [ "January" "February" "March" "April" "May" "June" "July" "August"
"September" "October" "November" "December" ].
 
time localtime [ [0 at 'd 4 4 format] ["-"] [1 at 'd 2 2 format] ["-"] [2 at 'd 2 2 format] ]
[i] map [putchars] step '\n putch pop.
 
time localtime [ [8 at pred weekdays of] [", "] [1 at pred months of] [" "] [2 at 'd 1 1 format]
[", "] [0 at 'd 4 4 format] ] [i] map [putchars] step '\n putch pop.
</syntaxhighlight>
</lang>
 
=={{header|jq}}==
{{works with|jq|with strftime}}
<langsyntaxhighlight lang="sh">$ jq -n 'now | (strftime("%Y-%m-%d"), strftime("%A, %B %d, %Y"))'
"2015-07-02"
"Thursday, July 02, 2015"</langsyntaxhighlight>
 
WARNING: prior to July 2, 2015, there was a bug in jq affecting the display of the "day of week" (wday) and the "day of the year" (yday).
Line 2,039 ⟶ 2,285:
{{works with|Julia|0.6}}
 
<langsyntaxhighlight lang="julia">ts = Dates.today()
 
println("Today's date is:")
println("\t$ts")
println("\t", Dates.format(ts, "E, U dd, yyyy"))</langsyntaxhighlight>
 
{{out}}
Line 2,051 ⟶ 2,297:
 
=={{header|Kotlin}}==
<langsyntaxhighlight lang="scala">// version 1.0.6
 
import java.util.GregorianCalendar
Line 2,059 ⟶ 2,305:
println("%tF".format(now))
println("%tA, %1\$tB %1\$te, %1\$tY".format(now))
}</langsyntaxhighlight>
 
{{out}}
Line 2,068 ⟶ 2,314:
 
=={{header|langur}}==
<syntaxhighlight lang="langur">var .now = dt//
{{works with|langur|0.10.1}}
<lang langur>var .now = dt//
var .format1 = "2006-01-02"
var .format2 = "Monday, January 2, 2006"
writeln $"\.now:dt. format1;"
writeln $"\.now:dt. format2;"</langsyntaxhighlight>
 
<syntaxhighlight lang="langur">var .now = dt//
{{works with|langur|0.9.3}}
<lang langur>var .now = dt//
writeln $"\.now:dt(2006-01-02);"
writeln $"\.now:dt(Monday, January 2, 2006);"</langsyntaxhighlight>
 
<syntaxhighlight lang="langur">writeln string dt//, "2006-01-02"
{{works with|langur|0.9}}
<lang langur>writeln toStringstring dt//, "Monday, January 2, 2006-01-02"</syntaxhighlight>
writeln toString dt//, "Monday, January 2, 2006"</lang>
 
{{out}}
Line 2,103 ⟶ 2,346:
 
=={{header|Lasso}}==
<syntaxhighlight lang="lasso">
<lang Lasso>
date('11/10/2007')->format('%Q') // 2007-11-10
date('11/10/2007')->format('EEEE, MMMM d, YYYY') //Saturday, November 10, 2007
 
</syntaxhighlight>
</lang>
 
=={{header|Liberty BASIC}}==
<langsyntaxhighlight lang="lb">'Display the current date in the formats of "2007-11-10"
d$=date$("yyyy/mm/dd")
print word$(d$,1,"/")+"-"+word$(d$,2,"/")+"-"+word$(d$,3,"/")
Line 2,132 ⟶ 2,375:
monthLong$="January February March April May June July August September October November December"
 
print word$(weekDay$,theDay+1);", ";word$(monthLong$,month);" ";day;", ";year</langsyntaxhighlight>
 
 
=={{header|LiveCode}}==
<syntaxhighlight lang="livecode">on mouseUp pButtonNumber
put the date into tDate
convert tDate to dateItems
put item 1 of tDate & "-" & item 2 of tDate & "-" & item 3 of tDate & return into tMyFormattedDate
put tMyFormattedDate & the long date
end mouseUp </syntaxhighlight>
 
=={{header|Logo}}==
{{works with|UCB Logo}}
A bit of a cheat since Logo has no standard built-in time and date functions, but UCB Logo can call out to the shell, so:
<langsyntaxhighlight lang="logo">
print first shell [date +%F]
print first shell [date +"%A, %B %d, %Y"]
</syntaxhighlight>
</lang>
{{Out}}
<pre>2020-09-16
Line 2,146 ⟶ 2,398:
 
=={{header|Lua}}==
<langsyntaxhighlight lang="lua">print( os.date( "%Y-%m-%d" ) )
print( os.date( "%A, %B %d, %Y" ) )</langsyntaxhighlight>
 
=={{header|M2000 Interpreter}}==
<syntaxhighlight lang="m2000 interpreter">
<lang M2000 Interpreter>
Print str$(today, "yyyy-mm-dd")
Print str$(today, "dddd, mmm, dd, yyyy")
</syntaxhighlight>
</lang>
 
=={{header|Maple}}==
 
<syntaxhighlight lang="maple">
<lang Maple>
with(StringTools);
FormatTime("%Y-%m-%d")
FormatTime("%A,%B %d, %y")
</syntaxhighlight>
</lang>
 
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<langsyntaxhighlight Mathematicalang="mathematica">DateString[{"Year", "-", "Month", "-", "Day"}]
DateString[{"DayName", ", ", "MonthName", " ", "Day", ", ", "Year"}]</langsyntaxhighlight>
 
=={{header|MATLAB}} / {{header|Octave}}==
<langsyntaxhighlight MATLABlang="matlab">>> datestr(now,'yyyy-mm-dd')
 
ans =
Line 2,178 ⟶ 2,430:
ans =
 
Friday, June 18, 2010</langsyntaxhighlight>
 
=={{header|min}}==
{{works with|min|0.19.3}}
<langsyntaxhighlight lang="min">("YYYY-MM-dd" "dddd, MMMM dd, YYYY") ('timestamp dip tformat puts!) foreach</langsyntaxhighlight>
{{out}}
<pre>
2019-04-02
Tuesday, April 02, 2019
</pre>
 
=={{header|MiniScript}}==
<syntaxhighlight lang="miniscript">import "dateTime"
 
print dateTime.now("yyyy-MM-dd")
print dateTime.now("dddd, MMMM d, yyyy")</syntaxhighlight>
 
{{out}}
<pre>2023-12-28
Thursday, December 28, 2023
</pre>
 
=={{header|mIRC Scripting Language}}==
<langsyntaxhighlight lang="mirc">echo -ag $time(yyyy-mm-dd)
echo -ag $time(dddd $+ $chr(44) mmmm dd $+ $chr(44) yyyy)</langsyntaxhighlight>
 
=={{header|MUMPS}}==
{{works with|MUMPS|Intersystems' Caché|(all versions)}}
Functions starting with 'Z' or '$Z' are implementation specific.
<langsyntaxhighlight MUMPSlang="mumps">DTZ
WRITE !,"Date format 3: ",$ZDATE($H,3)
WRITE !,"Or ",$ZDATE($H,12),", ",$ZDATE($H,9)
QUIT</langsyntaxhighlight>
<p>MUMPS contains the integer number of days since December 31, 1840 in the first part of the system variable $HOROLOG.</p>
{{works with|MUMPS|all}}
<langsyntaxhighlight MUMPSlang="mumps">DTM(H)
;You can pass an integer, but the default is to use today's value
SET:$DATA(H)=0 H=$HOROLOG
Line 2,222 ⟶ 2,485:
WRITE !,$P(DN,",",DOW),", ",$P(MN,",",MO)," ",DA,", ",YR
KILL Y,YR,RD,MC,MO,DA,MN,DN,DOW
QUIT</langsyntaxhighlight>
Demos:<pre>
USER>D DTM^ROSETTA
Line 2,239 ⟶ 2,502:
 
=={{header|Nanoquery}}==
<langsyntaxhighlight Nanoquerylang="nanoquery">import Nanoquery.Util
 
d = new(Date)
println d.getYear() + "-" + d.getMonth() + "-" + d.getDay()
println d.getDayOfWeek() + ", " + d.getMonthName() + " " + d.getDay() + ", " + d.getYear()</langsyntaxhighlight>
 
=={{header|Neko}}==
<syntaxhighlight lang="actionscript">/**
<lang ActionScript>/**
<doc>
<h2>Date format</h2>
Line 2,259 ⟶ 2,522:
var now = date_now()
$print(date_format(now, "%F"), "\n")
$print(date_format(now, "%A, %B %d, %Y"), "\n")</langsyntaxhighlight>
{{out}}
<pre>prompt$ nekoc date-format.neko
Line 2,267 ⟶ 2,530:
 
=={{header|NetRexx}}==
<syntaxhighlight lang="netrexx">
<lang NetRexx>
import java.text.SimpleDateFormat
say SimpleDateFormat("yyyy-MM-dd").format(Date())
say SimpleDateFormat("EEEE, MMMM dd, yyyy").format(Date())
</syntaxhighlight>
</lang>
{{out}}
<pre>2019-02-10
Line 2,277 ⟶ 2,540:
 
=={{header|NewLISP}}==
<langsyntaxhighlight NewLISPlang="newlisp">; file: date-format.lsp
; url: http://rosettacode.org/wiki/Date_format
; author: oofoe 2012-02-01
Line 2,310 ⟶ 2,573:
(println "long: " (date (date-value) 0 "%A, %B %#d, %Y"))
 
(exit)</langsyntaxhighlight>
 
{{out}}
Line 2,320 ⟶ 2,583:
 
=={{header|Nim}}==
<langsyntaxhighlight Nimlang="nim">import times
 
var t = now()
echo(t.format("yyyy-MM-dd"))
echo(t.format("dddd',' MMMM d',' yyyy"))</langsyntaxhighlight>
 
=={{header|Objeck}}==
<langsyntaxhighlight lang="objeck">
use IO;
use Time;
Line 2,343 ⟶ 2,606:
}
}
</syntaxhighlight>
</lang>
 
{{out}}
Line 2,352 ⟶ 2,615:
 
=={{header|Objective-C}}==
<langsyntaxhighlight lang="objc">NSLog(@"%@", [NSDate date]);
NSLog(@"%@", [[NSDate date] descriptionWithCalendarFormat:@"%Y-%m-%d" timeZone:nil locale:nil]);
NSLog(@"%@", [[NSDate date] descriptionWithCalendarFormat:@"%A, %B %d, %Y" timeZone:nil locale:nil]);</langsyntaxhighlight>
 
{{works with|Mac OS X|10.4+}}
{{works with|iOS}}
<langsyntaxhighlight lang="objc">NSLog(@"%@", [NSDate date]);
NSDateFormatter *dateFormatter = [[NSDateFormat alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd"];
NSLog(@"%@", [dateFormatter stringFromDate:[NSDate date]]);
[dateFormatter setDateFormat:@"EEEE, MMMM d, yyyy"];
NSLog(@"%@", [dateFormatter stringFromDate:[NSDate date]]);</langsyntaxhighlight>
 
=={{header|OCaml}}==
 
<langsyntaxhighlight lang="ocaml"># #load "unix.cma";;
# open Unix;;
 
Line 2,379 ⟶ 2,642:
 
# Printf.sprintf "%d-%02d-%02d" (1900 + gmt.tm_year) (1 + gmt.tm_mon) gmt.tm_mday ;;
- : string = "2008-08-29"</langsyntaxhighlight>
 
<langsyntaxhighlight lang="ocaml">let months = [| "January"; "February"; "March"; "April"; "May"; "June";
"July"; "August"; "September"; "October"; "November"; "December" |]
 
Line 2,392 ⟶ 2,655:
gmt.tm_mday
(1900 + gmt.tm_year) ;;
- : string = "Friday, August 29, 2008"</langsyntaxhighlight>
 
=={{header|ooRexx}}==
<langsyntaxhighlight ooRexxlang="oorexx">/* REXX */
dats='20071123'
Say date('I',dats,'S')
Line 2,402 ⟶ 2,665:
dati=date('I')
Say dati
Say date('W',dati,'I')',' date('M',dati,'I') translate('ij, abcd',dati,'abcdefghij')</langsyntaxhighlight>
{{out}}2007-11-23
Friday, November 23, 2007
Line 2,410 ⟶ 2,673:
 
=={{header|OxygenBasic}}==
<langsyntaxhighlight lang="oxygenbasic">
extern lib "kernel32.dll"
 
Line 2,442 ⟶ 2,705:
print "" t.wYear "-" month "-" day
print WeekDay[t.wDayOfWeek+1 and 7 ] " " MonthName[t.wMonth and 31] " " t.wDay " " t.wYear
</syntaxhighlight>
</lang>
 
=={{header|Oz}}==
Getting the current local date is easy, but we have to do the formatting manually.
<langsyntaxhighlight lang="oz">declare
WeekDays = unit(0:"Sunday" "Monday" "Tuesday" "Wednesday"
"Thursday" "Friday" "Saturday")
Line 2,471 ⟶ 2,734:
in
{System.showInfo {DateISO {OS.localTime}}}
{System.showInfo {DateLong {OS.localTime}}}</langsyntaxhighlight>
 
=={{header|Pascal}}==
{{works with|Turbo Pascal|5.5}}
<langsyntaxhighlight Pascallang="pascal">program dateform;
uses DOS;
 
Line 2,529 ⟶ 2,792:
mname := m2s(mo); dname := d2s(dow);
writeln(dname,', ',mname,' ',dy,', ',yr)
end.</langsyntaxhighlight>
 
{{out}}
Line 2,537 ⟶ 2,800:
=={{header|Perl}}==
{{libheader|POSIX}}
<langsyntaxhighlight lang="perl">use POSIX;
 
print strftime('%Y-%m-%d', 0, 0, 0, 10, 10, 107), "\n";
print strftime('%A, %B %d, %Y', 0, 0, 0, 10, 10, 107), "\n";</langsyntaxhighlight>
 
{{out}} with locales '''C''':
Line 2,551 ⟶ 2,814:
 
Actual date:
<langsyntaxhighlight lang="perl">use POSIX;
 
print strftime('%Y-%m-%d', localtime), "\n";
print strftime('%A, %B %d, %Y', localtime), "\n";</langsyntaxhighlight>
 
{{out}} with locales '''C''':
Line 2,562 ⟶ 2,825:
=={{header|Phix}}==
{{libheader|Phix/basics}}
<!--<langsyntaxhighlight Phixlang="phix">(phixonline)-->
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">include</span> <span style="color: #000000;">builtins</span><span style="color: #0000FF;">\</span><span style="color: #004080;">timedate</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span>
<span style="color: #0000FF;">?</span><span style="color: #7060A8;">format_timedate</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">date</span><span style="color: #0000FF;">(),</span><span style="color: #008000;">"YYYY-MM-DD"</span><span style="color: #0000FF;">)</span>
<span style="color: #0000FF;">?</span><span style="color: #7060A8;">format_timedate</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">date</span><span style="color: #0000FF;">(),</span><span style="color: #008000;">"Dddd, Mmmm d, YYYY"</span><span style="color: #0000FF;">)</span>
<!--</langsyntaxhighlight>-->
{{out}}
<pre>
Line 2,576 ⟶ 2,839:
=={{header|PHP}}==
Formatting rules: http://www.php.net/date
<langsyntaxhighlight lang="php"><?php
echo date('Y-m-d', time())."\n";
echo date('l, F j, Y', time())."\n";
?></langsyntaxhighlight>
 
=={{header|PicoLisp}}==
<langsyntaxhighlight PicoLisplang="picolisp">(let (Date (date) Lst (date Date))
(prinl (dat$ Date "-")) # 2010-02-19
(prinl # Friday, February 19, 2010
Line 2,591 ⟶ 2,854:
(caddr Lst)
", "
(car Lst) ) )</langsyntaxhighlight>
 
=={{header|Pike}}==
<syntaxhighlight lang="pike">
<lang Pike>
object cal = Calendar.ISO.Day();
write( cal->format_ymd() +"\n" );
Line 2,603 ⟶ 2,866:
cal->year_no());
write( special +"\n" );
</syntaxhighlight>
</lang>
{{Out}}
<pre>
Line 2,612 ⟶ 2,875:
=={{header|PL/I}}==
===Version 1===
<langsyntaxhighlight lang="pli">df: proc Options(main);
declare day_of_week(7) character (9) varying initial(
'Sunday','Monday','Tuesday','Wednesday',
Line 2,626 ⟶ 2,889:
put edit(substr(today,1,3),' ',substr(today,4,2),', ',
substr(today,6,4))(A);
end;</langsyntaxhighlight>
{{out}}
<pre>2013-11-02
Line 2,632 ⟶ 2,895:
 
===Version 2===
<langsyntaxhighlight PLlang="pl/Ii"> df: proc Options(Main);
declare day_of_week(7) character(9) varying initial(
'Sunday','Monday','Tuesday','Wednesday',
Line 2,647 ⟶ 2,910:
put edit(month(substr(today,1,2)),' ',substr(today,3,2),', ',
substr(today,5,4))(A);
End;</langsyntaxhighlight>
{{out}}
<pre>2013-11-02
Line 2,653 ⟶ 2,916:
 
=={{header|PowerShell}}==
<langsyntaxhighlight lang="powershell">"{0:yyyy-MM-dd}" -f (Get-Date)
"{0:dddd, MMMM d, yyyy}" -f (Get-Date)
# or
(Get-Date).ToString("yyyy-MM-dd")
(Get-Date).ToString("dddd, MMMM d, yyyy")</langsyntaxhighlight>
''Note:'' The names of months and days follow the currently set locale but otherwise the format is unchanged.
 
Line 2,664 ⟶ 2,927:
{{works with|SWI-Prolog|6}}
 
<langsyntaxhighlight lang="prolog">
display_date :-
get_time(Time),
Line 2,670 ⟶ 2,933:
format_time(atom(Long), '%A, %B %d, %Y', Time),
format('~w~n~w~n', [Short, Long]).
</syntaxhighlight>
</lang>
 
=={{header|PureBasic}}==
{{works with|PureBasic|4.41}}
<langsyntaxhighlight PureBasiclang="purebasic">;Declare Procedures
Declare.s MonthInText()
Declare.s DayInText()
Line 2,714 ⟶ 2,977:
EndSelect
ProcedureReturn m$
EndProcedure</langsyntaxhighlight>
 
=={{header|Python}}==
Formatting rules: http://docs.python.org/lib/module-time.html (strftime)
 
<langsyntaxhighlight lang="python">import datetime
today = datetime.date.today()
# The first requested format is a method of datetime objects:
Line 2,732 ⟶ 2,995:
# Since Python 3.6, f-strings allow the value to be inserted inline
f"The date is {d:%A, %B %d, %Y}"
</syntaxhighlight>
</lang>
 
=={{header|R}}==
strftime is short for "string format time".
<langsyntaxhighlight lang="rsplus">now <- Sys.time()
strftime(now, "%Y-%m-%d")
strftime(now, "%A, %B %d, %Y")</langsyntaxhighlight>
 
=={{header|Racket}}==
Line 2,752 ⟶ 3,015:
See: http://srfi.schemers.org/srfi-19/srfi-19.html
 
<langsyntaxhighlight lang="racket">#lang racket
(require srfi/19)
 
Line 2,764 ⟶ 3,027:
(displayln (date->string (current-date) "~A, ~B ~d, ~Y"))
;;; ~e is space padded day of month:
(displayln (date->string (current-date) "~A, ~B ~e, ~Y"))</langsyntaxhighlight>
both ~d and ~e satisfy the format required, since the "10" part of that date is 2-digit
 
Line 2,775 ⟶ 3,038:
(formerly Perl 6)
{{libheader|DateTime&#58;&#58;Format}}
<syntaxhighlight lang="raku" perl6line>use DateTime::Format;
 
my $dt = DateTime.now;
 
say strftime('%Y-%m-%d', $dt);
say strftime('%A, %B %d, %Y', $dt);</langsyntaxhighlight>
 
The built-in Date and DateTime classes both offer support for the ISO format:
<syntaxhighlight lang="raku" perl6line>my $d = Date.today;
 
say $d.yyyy-mm-dd;</langsyntaxhighlight>
 
They don't include the longer format specified in the task, but you can always roll your own formatter instead of importing the library:
 
<syntaxhighlight lang="raku" perl6line>my @months = <January February March April May June July
August September October November December>;
my @days = <Monday Tuesday Wednesday Thursday Friday Saturday Sunday>;
Line 2,796 ⟶ 3,059:
 
say $d.yyyy-mm-dd; # still works
say $d; # uses our formatter sub</langsyntaxhighlight>
 
=={{header|Raven}}==
<syntaxhighlight lang ="raven">time int as today</langsyntaxhighlight>
 
Short form:
 
<langsyntaxhighlight lang="raven">today '%Y-%m-%d' date</langsyntaxhighlight>
 
Long form:
 
<langsyntaxhighlight lang="raven">today '%A, %B %d, %Y' date</langsyntaxhighlight>
 
=={{header|REBOL}}==
<langsyntaxhighlight REBOLlang="rebol">REBOL [
Title: "Date Formatting"
URL: http://rosettacode.org/wiki/Date_format
Line 2,832 ⟶ 3,095:
pick system/locale/months now/month " "
now/day ", " now/year
]</langsyntaxhighlight>
 
{{out}}
Line 2,839 ⟶ 3,102:
Sunday, December 6, 2009</pre>
=={{header|RED}}==
<syntaxhighlight lang="red">
<lang RED>
Red []
;; zeropad
Line 2,848 ⟶ 3,111:
print rejoin [d/year "-" f2n d/month "-" f2n d/day]
print rejoin [system/locale/days/(d/weekday) ", " system/locale/months/(d/month) " " f2n d/day ", " d/year]
</syntaxhighlight>
</lang>
{{out}}<pre>2020-03-25
Wednesday, March 25, 2020
Line 2,856 ⟶ 3,119:
<br>It's up to the programmer to choose whatever version of the &nbsp; '''date''' &nbsp; BIF that best serves the purpose.
===idiomatic version===
<langsyntaxhighlight REXXlang="rexx">/*REXX pgm shows current date: yyyy-mm-dd & Dayofweek, Month dd, yyyy*/
x = date('S') /*get current date as yyyymmdd */
yyyy = left(x,4) /*pick off year (4 digs).*/
Line 2,867 ⟶ 3,130:
zdd = dd+0 /*remove leading zero from DD */
say weekday',' month zdd"," yyyy /*format date as: Month dd, yyyy*/
/*stick a fork in it, we're done.*/</langsyntaxhighlight>
{{out}}
<pre>
Line 2,875 ⟶ 3,138:
 
===compact version===
<langsyntaxhighlight lang="rexx">/*REXX pgm shows current date: yyyy-mm-dd & Dayofweek, Month dd, yyyy*/
/* ╔══════════════════════════════════════════════════════════════════╗
║ function returns a specific example ║
Line 2,902 ⟶ 3,165:
say date('W')"," date('M') word(date(), 1)"," yyyy
/* [↑] dayofweek Month dd, yyyy*/
/*stick a fork in it, we're done.*/</langsyntaxhighlight>
'''output''' would be the same as the 1<sup>st</sup> version.
 
===modern version===
This version can be used with those REXXes that support the &nbsp; '''I''' &nbsp; (ISO) parameter for the &nbsp; '''date''' &nbsp; BIF.
<langsyntaxhighlight REXXlang="rexx">/*REXX pgm shows current date: yyyy-mm-dd & Dayofweek, Month dd, yyyy*/
say date('I') /*yyyy-mm-dd with leading zeroes.*/
 
Line 2,913 ⟶ 3,176:
/* [↑] dayofweek Month dd, yyyy*/
/*stick a fork in it, we're done.*/
</syntaxhighlight>
</lang>
'''output''' would be the same as the 1<sup>st</sup> version.
<br><br>
 
=={{header|Ring}}==
<syntaxhighlight lang="c">
<lang ring>
dateStr = date()
date1 = timelist()[19] + "-" + timelist()[10] + "-" + timelist()[6]
Line 2,925 ⟶ 3,188:
? date1
? date2
 
</lang>
/*
timelist() ---> List contains the time and date information.
Index Value
----------------------------
1 - abbreviated weekday name
2 - full weekday name
3 - abbreviated month name
4 - full month name
5 - Date & Time
6 - Day of the month
7 - Hour (24)
8 - Hour (12)
9 - Day of the year
10 - Month of the year
11 - Minutes after hour
12 - AM or PM
13 - Seconds after the hour
14 - Week of the year (sun-sat)
15 - day of the week
16 - date
17 - time
18 - year of the century
19 - year
20 - time zone
21 - percent sign
*/
 
</syntaxhighlight>
{{out}}
<pre>
Line 2,931 ⟶ 3,222:
2020-07-19
Sunday, July 19, 2020
</pre>
 
=={{header|RPL}}==
RPL can return the date as a floating point number (format dd.mmyyyy) and can convert it (along with the time) as a string (format "DAY dd.mm.yy hh.mm.ss")
To solve the task, some formatting is then needed.
{{works with|HP|48}}
≪ DATE DUP 1000000 * 10000 MOD "-" +
OVER FP 100 * IP + "-" +
SWAP IP +
≫ '<span style="color:blue">DTSHORT</span>' STO
≪ { "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday" "Sunday" }
{ "MON" "TUE" "WED" "THU" "FRI" "SAT" "SUN" }
DATE TIME TSTR 1 3 SUB POS GET ", " +
{ "January" "February" "March" "April" "May" "June" "July" "August" "September" "October" "November" "December"}
DATE FP 100 * IP GET + " " +
OVER IP + ", " +
DATE 1000000 * 10000 MOD +
≫ '<span style="color:blue">DTLONG</span>' STO
{{out}}
<pre>
2: "2023-8-17"
1: "Thursday, August 17, 2023"
</pre>
 
Line 2,936 ⟶ 3,250:
Formatting rules: [//www.ruby-doc.org/core/Time.html#method-i-strftime Time#strftime]
 
<langsyntaxhighlight lang="ruby">puts Time.now
puts Time.now.strftime('%Y-%m-%d')
puts Time.now.strftime('%F') # same as %Y-%m-%d (ISO 8601 date formats)
puts Time.now.strftime('%A, %B %d, %Y')</langsyntaxhighlight>
{{out}}
<pre>
Line 2,949 ⟶ 3,263:
 
=={{header|Run BASIC}}==
<langsyntaxhighlight lang="runbasic">'Display the current date in the formats of "2007-11-10" and "Sunday, November 10, 2007".
print date$("yyyy-mm-dd")
print date$("dddd");", "; 'return full day of the week (eg. Wednesday
print date$("mmmm");" "; 'return full month name (eg. March)
print date$("dd, yyyy") 'return day, year</langsyntaxhighlight>
{{out}}
<pre>
Line 2,962 ⟶ 3,276:
=={{header|Rust}}==
Using <code>chrono 0.4.6</code>
<langsyntaxhighlight lang="rust">fn main() {
let now = chrono::Utc::now();
println!("{}", now.format("%Y-%m-%d"));
println!("{}", now.format("%A, %B %d, %Y"));
}</langsyntaxhighlight>
 
=={{header|Scala}}==
<syntaxhighlight lang ="scala">val now=new Date()
import java.util.Date
 
val now=new Date()
println("%tF".format(now))
println("%1$tA, %1$tB %1$td, %1$tY".format(now))</langsyntaxhighlight>
 
{{out}}
<pre>
2023-04-17
Monday, April 17, 2023
</pre>
 
=={{header|Scheme}}==
Line 2,977 ⟶ 3,300:
{{works with|Guile|2.0.13}}
 
<langsyntaxhighlight Schemelang="scheme">(define short-date
(lambda (lt)
(strftime "%Y-%m-%d" (localtime lt))))
Line 2,994 ⟶ 3,317:
(display (long-date dt))(newline))))
 
</syntaxhighlight>
</lang>
 
=={{header|Seed7}}==
<langsyntaxhighlight lang="seed7">$ include "seed7_05.s7i";
include "time.s7i";
Line 3,010 ⟶ 3,333:
writeln(strDate(now));
writeln(days[dayOfWeek(now)] <& ", " <& months[now.month] <& " " <& now.day <& ", " <& now.year);
end func;</langsyntaxhighlight>
 
=={{header|SenseTalk}}==
<langsyntaxhighlight lang="sensetalk">
put formattedTime( "[year]-[month]-[day]", the date)
 
put formattedTime( "[weekday], [month name] [day], [year]", the date)
</syntaxhighlight>
</lang>
{{out}}
<pre>2019-12-18
Line 3,023 ⟶ 3,346:
 
=={{header|Shiny}}==
<langsyntaxhighlight lang="shiny">say time.format 'Y-m-d' time.now
say time.format 'l, F j, Y' time.now</langsyntaxhighlight>
 
=={{header|Sidef}}==
<langsyntaxhighlight lang="ruby">var time = Time.local;
say time.ctime;
say time.strftime("%Y-%m-%d");
say time.strftime("%A, %B %d, %Y");</langsyntaxhighlight>
{{out}}
<pre>
Line 3,041 ⟶ 3,364:
In Smalltalk, one sends a <tt>printFormat</tt> message to a Date object with year, month, and day. For other date strings, one must construct the date string from the parts of a Date object. Of course, you'd probably want to make a method for doing so.
 
<langsyntaxhighlight lang="smalltalk">| d |
d := Date today.
d printFormat: #(3 2 1 $- 1 1 2).
(d weekday asString), ', ', (d monthName), ' ', (d dayOfMonth asString), ', ', (d year asString)</langsyntaxhighlight>
{{works with|Smalltalk/X}}
<langsyntaxhighlight lang="smalltalk">d := Date today.
d printOn:Stdout format:'%y-%m-%d'. Stdout cr.
d printOn:Stdout format:'%(DayName), %(MonthName) %d, %y' language:#en. Stdout cr.
d printOn:Stdout format:'%(DayName), %(MonthName) %d, %y' language:#de. Stdout cr.
d printOn:Stdout format:'%(DayName), %(MonthName) %d, %y' language:#fr. Stdout cr.</langsyntaxhighlight>
{{out}}
<pre>2020-12-17
Line 3,056 ⟶ 3,379:
Donnerstag, Dezember 17, 2020
Vendredi, Décembre 17, 2020</pre>
 
=={{header|SparForte}}==
As a structured script. Does not use l10n package.
<syntaxhighlight lang="ada">#!/usr/local/bin/spar
pragma annotate( summary, "dateformat")
@( description, "Display the current date in the formats of '2007-11-10' " )
@( description, "and 'Sunday, November 10, 2007'." )
@( see_also, "http://rosettacode.org/wiki/Date_format" )
@( "Ken O. Burtch" );
pragma license( unrestricted );
 
pragma restriction( no_external_commands );
 
procedure dateformat is
function Month_Image (Month : calendar.month_number) return string is
begin
case Month is
when 1 => return "January";
when 2 => return "February";
when 3 => return "March";
when 4 => return "April";
when 5 => return "May";
when 6 => return "June";
when 7 => return "July";
when 8 => return "August";
when 9 => return "September";
when 10 => return "October";
when 11 => return "November";
when others => return "December";
end case;
end Month_Image;
function Day_Image (Day : integer) return string is
begin
case Day is
when 0 => return "Monday";
when 1 => return "Tuesday";
when 2 => return "Wednesday";
when 3 => return "Thursday";
when 4 => return "Friday";
when 5 => return "Saturday";
when others => return "Sunday";
end case;
end Day_Image;
Today : constant calendar.time := calendar.clock;
begin
--put_line(
--Put_Line (Image (Today) (1..10));
 
put( calendar.year( Today ), "9999" ) @( "-" )
@( calendar.month( Today ), "99" ) @( "-" )
@( calendar.day( Today ), "99" );
new_line;
 
put_line(
Day_Image( calendar.day_of_week( Today ) ) & ", " &
Month_Image( calendar.month( Today ) ) &
strings.image( calendar.day( Today ) ) & "," &
strings.image( calendar.year( Today ) ) );
end dateformat;</syntaxhighlight>
 
=={{header|SQL}}==
{{works with|Oracle}}
<langsyntaxhighlight lang="sql">
select to_char(sysdate,'YYYY-MM-DD') date_fmt_1 from dual;
 
select to_char(sysdate,'fmDay, Month DD, YYYY') date_fmt_2 from dual;
</syntaxhighlight>
</lang>
 
<pre>
Line 3,080 ⟶ 3,462:
Formatting rules: http://www.standardml.org/Basis/date.html#SIG:DATE.fmt:VAL
 
<langsyntaxhighlight lang="sml">print (Date.fmt "%Y-%m-%d" (Date.fromTimeLocal (Time.now ())) ^ "\n");
print (Date.fmt "%A, %B %d, %Y" (Date.fromTimeLocal (Time.now ())) ^ "\n");</langsyntaxhighlight>
{{out}}
<pre>
Line 3,092 ⟶ 3,474:
Stata has many ways to format dates, see [https://www.stata.com/help.cgi?Datetime_display_formats Datetime display formats] in the documentation.
 
<langsyntaxhighlight lang="stata">display %tdCCYY-NN-DD td($S_DATE)
display %tdDayname,_Month_dd,_CCYY td($S_DATE)</langsyntaxhighlight>
 
=={{header|Suneido}}==
<langsyntaxhighlight Suneidolang="suneido">Date().Format('yyyy-MM-dd') --> "2010-03-16"
Date().LongDate() --> "Tuesday, March 16, 2010" </langsyntaxhighlight>
 
=={{header|Swift}}==
<langsyntaxhighlight Swiftlang="swift">import Foundation
extension String {
func toStandardDateWithDateFormat(format: String) -> String {
Line 3,110 ⟶ 3,492:
}
 
let date = "2015-08-28".toStandardDateWithDateFormat("yyyy-MM-dd")</langsyntaxhighlight>
 
{{out}}
Line 3,118 ⟶ 3,500:
 
=={{header|Tcl}}==
<langsyntaxhighlight lang="tcl">set now [clock seconds]
puts [clock format $now -format "%Y-%m-%d"]
puts [clock format $now -format "%A, %B %d, %Y"]</langsyntaxhighlight>
 
=={{header|Terraform}}==
<langsyntaxhighlight lang="terraform">locals {
today = timestamp()
}
Line 3,133 ⟶ 3,515:
output "us-long" {
value = formatdate("EEEE, MMMM D, YYYY", local.today)
}</langsyntaxhighlight>
 
{{Out}}
Line 3,144 ⟶ 3,526:
 
=={{header|TUSCRIPT}}==
<langsyntaxhighlight lang="tuscript">
$$ MODE TUSCRIPT
SET dayofweek = DATE (today,day,month,year,number)
Line 3,172 ⟶ 3,554:
PRINT format1
PRINT format2
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 3,180 ⟶ 3,562:
 
=={{header|UNIX Shell}}==
<langsyntaxhighlight lang="bash">date +"%Y-%m-%d"
date +"%A, %B %d, %Y"</langsyntaxhighlight>
 
On a new enough system <code>%F</code> is equivalent to <code>%Y-%m-%d</code>
<langsyntaxhighlight lang="bash">date +"%F"</langsyntaxhighlight>
 
<!-- ENHANCE-ME: what is new enough for %F ? For example it doesn't appear in these bits of POSIX,
Line 3,194 ⟶ 3,576:
{{works with|Cygnus/X Ursa}}
Cygnus/X Ursa can import and call Java classes.
<langsyntaxhighlight lang="ursa">cygnus/x ursa v0.78 (default, release 0)
[Oracle Corporation JVM 1.8.0_51 on Mac OS X 10.10.5 x86_64]
> import "java.util.Date"
Line 3,206 ⟶ 3,588:
> out (sdf.format d) endl console
Saturday, July 23, 2016
> _</langsyntaxhighlight>
 
=={{header|Ursala}}==
The method is to transform a date in standard format returned by the library function, now.
<langsyntaxhighlight Ursalalang="ursala">#import std
#import cli
 
Line 3,226 ⟶ 3,608:
#show+
 
main = <.text_form,numeric_form> now0</langsyntaxhighlight>
{{out}}
<pre>Wednesday, June 24, 2009
Line 3,233 ⟶ 3,615:
=={{header|VB-DOS|PDS 7.1 BASIC}}==
{{works with|Visual Basic for DOS and PDS 7.1}}
<syntaxhighlight lang="vb">
<lang vb>
OPTION EXPLICIT
 
Line 3,272 ⟶ 3,654:
 
END
</syntaxhighlight>
</lang>
 
=={{header|VBA}}==
 
<langsyntaxhighlight VBAlang="vba">Function DateFormats()
Debug.Print Format(Date, "yyyy-mm-dd")
Debug.Print Format(Date, "dddd, mmmm dd yyyy")
End Function</langsyntaxhighlight>
 
=={{header|VBScript}}==
<syntaxhighlight lang="vb">
<lang vb>
'YYYY-MM-DD format
WScript.StdOut.WriteLine Year(Date) & "-" & Right("0" & Month(Date),2) & "-" & Right("0" & Day(Date),2)
Line 3,288 ⟶ 3,670:
'Weekday_Name, Month_Name DD, YYYY format
WScript.StdOut.WriteLine FormatDateTime(Now,1)
</syntaxhighlight>
</lang>
 
{{Out}}
Line 3,299 ⟶ 3,681:
Display current date in format "2007-11-10":
 
<langsyntaxhighlight lang="vedit">Date(REVERSE+NOMSG+VALUE, '-')</langsyntaxhighlight>
 
Display current date in format "Sunday, November 10, 2007" (Requires VEDIT 6.2):
<langsyntaxhighlight lang="vedit">// Get todays date into #1, #2, #3 and #7
#1 = Date_Day
#2 = Date_Month
Line 3,332 ⟶ 3,714:
 
// Display the date string
RT(1) M(", ") RT(2) M(" ") NT(#1, LEFT+NOCR) M(",") NT(#3)</langsyntaxhighlight>
 
To insert the date string into edit buffer instead of displaying it, replace the last line with this:
 
<langsyntaxhighlight lang="vedit">RI(1) IT(", ") RI(2) IT(" ") NI(#1, LEFT+NOCR) IT(",") NI(#3)</langsyntaxhighlight>
 
=={{header|Vim Script}}==
See `:help strftime` - this function uses the C strftime() arguments' format.
<syntaxhighlight lang="vim">
echo strftime("%Y-%m-%d")
echo strftime("%A, %B %d, %Y")
</syntaxhighlight>
 
=={{header|V (Vlang)}}==
 
<syntaxhighlight lang="v (vlang)">import time
 
fn main() {
println(time.now().custom_format("YYYY-MM-DD"))
println(time.now().custom_format("dddd, MMMM D, YYYY"))
}</syntaxhighlight>
{{out}}
<pre>
2011-12-02
Friday, December 2, 2011
</pre>
 
=={{header|Wren}}==
{{libheader|Wren-date}}
Unless it is embedded in a host application, Wren currently has no direct way to obtain the current date. We therefore assume this is passed in by the user as a command line parameter.
<langsyntaxhighlight ecmascriptlang="wren">import "os" for Process
import "./date" for Date
 
var args = Process.arguments
Line 3,350 ⟶ 3,753:
var current = Date.parse(args[0])
System.print(current.format(Date.isoDate))
System.print(current.format("dddd|, |mmmm| |d|, |yyyy"))</langsyntaxhighlight>
 
{{out}}
Line 3,360 ⟶ 3,763:
 
=={{header|XPL0}}==
<langsyntaxhighlight XPL0lang="xpl0">include c:\cxpl\codes;
int CpuReg, Year, Month, Day, DName, MName, WDay;
[CpuReg:= GetReg; \access CPU registers
Line 3,378 ⟶ 3,781:
Text(0, DName(WDay)); Text(0, ", "); Text(0, MName(Month)); Text(0, " ");
IntOut(0, Day); Text(0, ", "); IntOut(0, Year); CrLf(0);
]</langsyntaxhighlight>
 
{{out}}
Line 3,387 ⟶ 3,790:
 
=={{header|Yabasic}}==
<langsyntaxhighlight Yabasiclang="yabasic">dim n$(1)
 
n = token(date$, n$(), "-")
Line 3,414 ⟶ 3,817:
return month$(int(n/3) + 1)
end sub</langsyntaxhighlight>
 
=={{header|zkl}}==
<langsyntaxhighlight lang="zkl">"%d-%02d-%02d".fmt(Time.Clock.localTime.xplode()).println()
//--> "2014-02-28" (ISO format)</langsyntaxhighlight>
Not quite but close. Even though localTime returns a 7 tuple (and xplode pushes all 7 as call args), fmt only eats what it needs.
<langsyntaxhighlight lang="zkl">Time.Date.prettyDay(Time.Clock.localTime.xplode())
//--> "Friday, the 28th of February 2014"</langsyntaxhighlight>
<langsyntaxhighlight lang="zkl">y,m,d:=Time.Clock.localTime; D:=Time.Date;
"%s, %s %d, %d".fmt(D.dayName(D.weekDay(y,m,d)),
D.monthName(m), d,y)
//-->"Friday, February 28, 2014"</langsyntaxhighlight>
 
=={{header|zonnon}}==
<langsyntaxhighlight lang="zonnon">
module Main;
import System;
Line 3,439 ⟶ 3,842:
System.Console.WriteLine("{0}, {1}",now.DayOfWeek,now.ToString("MMMM dd, yyyy"));
end Main.
</syntaxhighlight>
</lang>
{{Out}}
<pre>
885

edits