[pmwiki-users] {(...)} markup recipe available

Patrick R. Michaud pmichaud at pobox.com
Wed Apr 11 13:48:50 CDT 2007


On Wed, Apr 11, 2007 at 06:15:56PM +0200, Hladůvka Jiří wrote:
> I am missing the european date format %d/%m/%Y or %d-%m-%Y
> Or can I just put into the markup such a format ?

Short answer: 

You can just put that into the markup directly, as in

    {(ftime '%d/%m/%Y')}

Almost any format will work -- the %... items simply say where
to plug in various time values.


Long answer:

The format to {(ftime ...)} is just using the same
format as PHP's strftime() function [1], where a %+letter
combination indicates a place for a value of some sort to be
substituted.  So, the formatting is essentially unrestricted.
See PHP's documentation on strftime [2] for complete details,
but here's a short list of the most useful substitutions:

    %d - day of month (01 to 31)
    %m - month as decimal number (01 to 12)
    %Y - 4 digit year

    %H - hour on 24-hour clock (00 to 23)
    %M - minutes (00 to 59)
    %S - seconds (00 to 60)

    %F - date as %Y-%m-%d  (ISO 8901 standard)
    %T - time as %H:%M:%S
    %Z - time zone or name or abbreviation
    %s - unix timestamp (number of seconds since Epoch)

    %I - hour on 12-hour clock (01 to 12)
    %l - hour on 12-hour clock, single digit has leading space (' 1' to '12')
    %e - day of month, single digit has leading space (' 1' to '31')

  Locale-based (uses i18n settings):
    %A - full weekday              Wednesday / mercredi / Mittwoch
    %a - abbreviated weekday       Wed       / mer      / Mi
    %B - full month                April     / avril    / April
    %b - abbreviated month         Apr       / avr      / Apr
    %p - 'am', 'pm', or local equivalent

As I said, there are many other formatting codes available (as well
as some shortcuts for specific localized variants) -- see the
strftime description for the full list.

Hope this helps,

Pm

[1] The strftime() function and its formats have application beyond 
    PHP... it's also standard in Perl, Python, Ruby, C, C++, Java, 
    and the Unix date(1) command, which is one reason I prefer it over
    PHP's "date" function.

[2] http://www.php.net/strftime




More information about the pmwiki-users mailing list