Sign in Join
Wiki copytemporary

RFC 1123 Time Format: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11[[Function]] RFC1123TimeFormat(aDateTime:[[TDateTime]]; isLocalTime:boolean):string; creates and displays the time in the RFC 1123 International format:
22
3-` DAY, DD MON YYYY hh:mm:ss GMT`
3+```text
4+ DAY, DD MON YYYY hh:mm:ss GMT
5+```
46
57e.g:
68
7-` Sun, 21 Oct 2018 12:16:24 GMT`
9+```text
10+ Sun, 21 Oct 2018 12:16:24 GMT
11+```
812
913Day in the form of DAY, three letter abbreviation followed by a [[Comma|comma]]. Date in the form DD-MON-YYYY (day, month, and year), where Month in the form three letter abbreviation.
1014
1115The date and time are displayed on the same line, date first followed by the time, and the time is in this format, with a space between the date's year and the hours, Time in the form hh:mm:ss (hours, minutes, and seconds)
1216
1317The time is Coordinated Universal Time (UTC), though the indication can optionally be Greenwich Mean Time (GMT)
1418
1519## program RFC1123_TimeFormat
1620
1721``` pascal
1822program RFC1123_TimeFormat;
1923
2024uses
2125 SysUtils, DateUtils;
2226
2327function RFC1123TimeFormat(aDateTime:TDateTime; isLocalTime:boolean):string;
2428const
2529 ShortDayNamesEnglish :array[1..7] of string =
2630 ('Sun', 'Mon','Tue', 'Wed', 'Thu', 'Fri', 'Sat');
2731 ShortMonthNamesEnglish :array[1..12] of string = ('Jan', 'Feb','Mar', 'Apr',
2832 'May','Jun','Jul','Aug', 'Sep','Oct','Nov','Dec');
2933var
3034 day,month : string;
3135 someDateTime:TDateTime;
3236begin
3337 if isLocalTime then someDateTime := LocalTimeToUniversal(aDateTime)
3438 else someDateTime := aDateTime;
3539 day := ShortDayNamesEnglish[DayOfWeek(someDateTime)];
3640 month := ShortMonthNamesEnglish[MonthOf(someDateTime)] ;
3741 result := day+', '+FormatDateTime('dd', someDateTime)+' '+
3842 month+' '+FormatDateTime('yyyy hh:nn:ss', someDateTime)+' GMT';
3943end;
4044
4145var
4246 someDate: TDateTime;
4347begin
4448 someDate := EncodeDate(2018, 10, 23);
4549 WriteLn(RFC1123TimeFormat(now,true));
4650 WriteLn(RFC1123TimeFormat(someDate,false));
4751 ReadLn;
4852end.
4953```
5054
5155[[Unit]] DateUtils function LocalTimeToUniversal convert local time to UTC time Declaration
5256
5357``` pascal
5458 function LocalTimeToUniversal( LT: TDateTime ):TDateTime;
5559```
5660
5761Unit SysUtils function FormatDateTime provides rich formatting of a TDateTime value into a string. Formatting is defined by the Formatting string.
5862
5963``` pascal
6064 function FormatDateTime ( const Formatting : string; DateTime : TDateTime ) : string;
6165```
6266
6367Unit SysUtils function EncodeDate build a TDateTime value from year, month and day values
6468
6569``` pascal
6670 function EncodeDate(Year, Month, Day :word): TDateTime;
6771```
6872
6973## See also
7074
7175- [[TDateTime]]
7276- Date and time format [[ISO 8601]]
7377
7478---
7579*From the Free Pascal wiki, page "RFC 1123 Time Format", as it stood on 2019-09-07 after a change by Kai Burghardt, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history