Ftime

Testing the MarkupExpression ftime

Testing the MarkupExpression ftime

Today is 2026-06-08 Mon in PmWikiland where its is 12:40:04

 {(ftime %F -7days)}
 {(ftime %F when="2007-08-14 -1days")}
 {(ftime %F when="2007-08-14 -1 days")}
 {(ftime %F when="2007-08-14 -1 day")}
 {(ftime %F "2007-04-11 -4 days")}

 {(ftime %F when="2007-01-24 +1 day")}
 {(ftime %F when="2007-01-24 +1day")}
 {(ftime %F "+1 day")} ?today +1 use quotes
 {(ftime %F +1day)} ?today +1
 2026-06-01
 2007-08-13
 2007-08-13
 2007-08-13
 2007-04-07

 2007-01-25
 2007-01-25
 2026-06-09 ?today +1 use quotes
 2026-06-09 ?today +1
 {(ftime when=" ")}
 {(ftime %s)}
 {(ftime %s " ")}
 {(ftime %s when="")}
 {(ftime fmt=%F when="2007-08-14 -1days")}
 December 31, 1969, at 11:59 PM
 1780922404
 -1
 -1
 2007-08-13
 {(ftime News-20070501)}
 May 01, 2007, at 12:00 AM
 {(ftime MarchingOrders2007)}
 June 08, 2026, at 12:40 PM
 {(ftime 1177600111)}
 June 08, 2026, at 12:40 PM
 {(ftime %s)}
 1780922404
 {(ftime @1177600111)}
 April 26, 2007, at 03:08 PM
 {(ftime fmt="%b %#d %Y" when="second mon of Jan")}
 {(ftime fmt="%b %#d %Y" when="second tue of Feb")}
 {(ftime fmt="%b %#d %Y" when="second wed of Mar")}
 {(ftime fmt="%b %e %Y" when="second thu of Apr")}
 {(ftime fmt="%b %e %Y" when="second fri of May")}
 {(ftime fmt="%b %e %Y" when="second sat of Jun")}
 {(ftime fmt="%b %e %Y" when="third  sun of Jul")}
 {(ftime fmt="%b %e %Y" when="fourth mon of Aug")}
 {(ftime fmt="%b %e %Y" when="first  tue of Sep")}
 {(ftime fmt="%b %e %Y" when="second wed of Oct")}
 {(ftime fmt="%b %e %Y" when="third  thu of Nov")}
 {(ftime fmt="%b %e %Y" when="first  wed of Dec")}
----
 {(ftime fmt="%b %e %Y" when="second Monday of January")}
 {(ftime fmt="%b %e %Y" when="second Tuesday of February")}
...
 {(ftime fmt="%b %e %Y" when="first Wednesday of December")}
 Jan 12 2026
 Feb 10 2026
 Mar 11 2026
 Apr  9 2026
 May  8 2026
 Jun 13 2026
 Jul 19 2026
 Aug 24 2026
 Sep  1 2026
 Oct 14 2026
 Nov 19 2026
 Dec  2 2026

 Jan 12 2026
 Feb 10 2026

...

 Dec  2 2026

All these work on my own server, with or without the changes in DRange() for 2.2.69. --Petko October 19, 2014, at 06:12 AM

Testing relative GNU date input formats

Today is 2026-06-08 Mon

? marks an unsatisfactory result
 {(ftime "%Y %b %d %a" "1 mon")}
 {(ftime "%Y %b %d %a" "2 tue")}
 {(ftime "%Y %b %d %a" "3 wed")}
 {(ftime "%Y %b %d %a" "4 thu")} ?

 {(ftime "%Y %b %d %a" "1 sat")}
 {(ftime "%Y %b %d %a" "2 sat")}
 {(ftime "%Y %b %d %a" "3 sat")}
 {(ftime "%Y %b %d %a" "4 sat")} 

 {(ftime "%Y %b %d %a" "tuesday")}
 {(ftime "%Y %b %d %a" "last tue")}
 {(ftime "%Y %b %d %a" "this tue")}
 {(ftime "%Y %b %d %a" "next tue")} ?
 {(ftime "%Y %b %d %a" "thursday")}

 {(ftime "%Y %b %d %a" "last week")}
 {(ftime "%Y %b %d %a" "this week")}
 {(ftime "%Y %b %d %a" "next week")}
 2026 Jun 08 Mon
 2026 Jun 16 Tue
 2026 Jun 24 Wed
 2026 Jul 02 Thu ?

 2026 Jun 13 Sat
 2026 Jun 20 Sat
 2026 Jun 27 Sat
 2026 Jul 04 Sat 

 2026 Jun 09 Tue
 2026 Jun 02 Tue
 2026 Jun 09 Tue
 2026 Jun 09 Tue ?
 2026 Jun 11 Thu

 2026 Jun 01 Mon
 2026 Jun 08 Mon
 2026 Jun 15 Mon

All the above are correct; "4 thu" means "Thursday the fourth week", knowing that "next Thursday" is "this Thursday" or "Thursday the first week". --Petko

 {(ftime "%Y %b %d %a" "last month")} ?
 {(ftime "%Y %b %d %a" "this month")}
 {(ftime "%Y %b %d %a" "next month")}

 {(ftime "%Y %b %d %a" "June")} ?
 {(ftime "%Y %b %d %a" "last June")} ?
 {(ftime "%Y %b %d %a" "this June")} ?
 {(ftime "%Y %b %d %a" "next June")} ?
 {(ftime "%Y %b %d %a" "last Aug")} ?
 {(ftime "%Y %b %d %a" "this Aug")} ?
 {(ftime "%Y %b %d %a" "next Aug")} ?
 {(ftime "%Y %b %d %a" "October")} ?
 {(ftime "%Y %b %d %a" "last Oct")} ?
 {(ftime "%Y %b %d %a" "this Oct")} ?
 {(ftime "%Y %b %d %a" "next Oct")} ?

 {(ftime "%Y %b %d %a" "last year")}
 {(ftime "%Y %b %d %a" "this year")}
 {(ftime "%Y %b %d %a" "next year")}
 2026 May 08 Fri ?
 2026 Jun 08 Mon
 2026 Jul 08 Wed

 2026 Jun 08 Mon ?
 2026 Jun 08 Mon ?
 2026 Jun 08 Mon ?
 2026 Jun 08 Mon ?
 2026 Jun 08 Mon ?
 2026 Jun 08 Mon ?
 2026 Jun 08 Mon ?
 2026 Oct 08 Thu ?
 2026 Jun 08 Mon ?
 2026 Jun 08 Mon ?
 2026 Jun 08 Mon ?

 2025 Jun 08 Sun
 2026 Jun 08 Mon
 2027 Jun 08 Tue
 {(ftime "%Y %b %d %a" "3 wed")}
 {(ftime "%Y %b %d %a" "wed 3")} ?
 {(ftime "%Y %b %d %a" "3 wed aug")} ?
 {(ftime "%Y %b %d %a" "aug 3 wed")} ?
 {(ftime "%Y %b %d %a" "aug wed 3")} ?

 {(ftime "%Y %b %d %a" "3 wed this aug")} ?
 {(ftime "%Y %b %d %a" "this aug 3 wed")} ?
 {(ftime "%Y %b %d %a" "3 wed aug this year")} ?
 {(ftime "%Y %b %d %a" "aug this year 3 wed")} ?
 {(ftime "%Y %b %d %a" "this year aug 3 wed")} ?
 {(ftime "%Y %b %d %a" "this year aug wed 3")} ?
 2026 Jun 24 Wed
 2026 Jun 08 Mon ?
 2026 Aug 26 Wed ?
 2026 Aug 05 Wed ?
 2026 Jun 08 Mon ?

 2026 Jun 08 Mon ?
 2026 Jun 08 Mon ?
 2026 Aug 26 Wed ?
 2026 Aug 26 Wed ?
 2026 Aug 05 Wed ?
 2026 Jun 08 Mon ?

If something is unsatisfactory with relative dates, the reason is the strtotime function in PHP, not PmWiki which uses the date this function recognizes and returns. See also Relative formats on which relative dates are recognized, for example "this/last/next Aug" is not among the ones that are expected to be recognized. --Petko October 19, 2014, at 06:08 AM

added Version 2.3.0 (2022-01-15)
 {(ftime %o)}
 {(ftime "%o")}
 {(ftime "%Y %b %d%o %a")}
 th
 th
 2026 Jun 08th Mon
added Version 2.3.12 (2022-09-25)
 {(ftime "%L")}
 {(ftime "%L" "-4minutes")}
 {(ftime "%L" "-4hours")}
 {(ftime "%L" "-4days")}
 {(ftime "%L" "-4months")}
 {(ftime "%L" "-4years")}
 {(ftime "%L" "2022-09-25")}

 {(ftime "%L" "-9months")}
 {(ftime "%L" "-10months")}
 {(ftime "%L" "-11months")}
 {(ftime "%L" "-12months")}

A stamp in the future is unexpected,\\
we should handle it better:
 {(ftime "%L" "+6days")}
 {(ftime "%L" "+6months")} (±DST)
 
 
 
 
 
 
 

 
 
 
 

A stamp in the future is unexpected,
we should handle it better:

 
  (±DST)
 0: 00.00 00.00 EnablePost = 1, keys=
 1: 00.00 00.00 config start
 2: 00.02 00.01 config end
 3: 00.04 00.03 MarkupToHTML begin
 4: 00.04 00.03 MarkupToHTML begin
 5: 00.05 00.04 MarkupToHTML end
 6: 00.05 00.04 MarkupToHTML begin
 7: 00.05 00.04 MarkupToHTML end
 8: 00.05 00.04 MarkupToHTML begin
 9: 00.05 00.04 MarkupToHTML end
10: 00.05 00.04 MarkupToHTML begin
11: 00.05 00.04 MarkupToHTML end
12: 00.05 00.04 MarkupToHTML begin
13: 00.05 00.04 MarkupToHTML end
14: 00.05 00.04 MarkupToHTML begin
15: 00.06 00.04 MarkupToHTML end
16: 00.06 00.04 MarkupToHTML begin
17: 00.06 00.04 MarkupToHTML end
18: 00.06 00.04 MarkupToHTML begin
19: 00.06 00.05 MarkupToHTML end
20: 00.06 00.05 MarkupToHTML begin
21: 00.06 00.05 MarkupToHTML end
22: 00.06 00.05 MarkupToHTML begin
23: 00.07 00.06 MarkupToHTML end
24: 00.07 00.06 MarkupToHTML begin
25: 00.07 00.06 MarkupToHTML end
26: 00.07 00.06 MarkupToHTML begin
27: 00.08 00.06 MarkupToHTML end
28: 00.08 00.06 MarkupToHTML begin
29: 00.08 00.07 MarkupToHTML end
30: 00.09 00.08 ReadApprovedUrls SiteAdmin.ApprovedUrls begin
31: 00.09 00.08 ReadApprovedUrls SiteAdmin.ApprovedUrls end
32: 00.11 00.10 MarkupToHTML end
33: 00.12 00.10 MarkupToHTML begin
34: 00.13 00.11 MarkupToHTML end
35: 00.14 00.12 MarkupToHTML begin
36: 00.14 00.12 MarkupToHTML end
37: 00.14 00.12 now
Peak memory: 4,019,024 bytes