DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:date

date Plugin

Compatible with DokuWiki

Detritus, Hrun, Elenor of Tsort

plugin A wrapper plugin for the php functions strftime and date

Last updated on
2016-08-28
Provides
Syntax
Repository
Source

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Tagged with date, strftime, syntax, time

Description

This plugin gives you the possibilities of the strftime or date function. With the relative date/time formats for the strtotime function you can create any date/time output you want.

Installation

Search and install the plugin using the Extension Manager. Refer to Plugins on how to install plugins manually.

For development version, see Development.

Examples/Usage

{{date>%A: %d.%m.%y}}

Gives you the current date in format: Dayname: DayNumber.MonthNumber.Year E.g. When today is Christmas 2014, then the output is: Wednesday: 24.12.2014

{{date>D, d M Y H:i:s O|timestamp=mktime(18, 25, 0, 12, 02, 2014)|mode=date}}

Gives you: Tue, 02 Dec 2014 18:25:00 +0000

Syntax

Basic syntax:

{{date>format|key1=value1|key2=value2...}}
  • format string to format the ouput, see PHP manual for strftime and date.
  • key can be one of this:
    • timestamp — If given, the transmitted timestamp is used instead of the current time/date.
    • now — Unix timestamp which is used as a base for the calculation of relative dates.
    • locale — set locale LC_TIME settings to specify the language in which the output is given.
    • mode=date — Use the date function instead the strftime function.

Only format is required. All parameter are optional. The sequence of the optional parameters is not important.

Parameters

timestamp

values: Unix timestamp

You can use strtotime or mktime here.

now

values: Unix timestamp

You can use strtotime or mktime here.

{{date>%d.%m.|timestamp=strtotime('next monday')|now=strtotime('last saturday')}}

Please note:

{{date>%A: %d.%m.%y|timestamp=strtotime("+1 day")|now=strtotime("Monday this week")}}

and

{{date>%A: %d.%m.%y|timestamp=strtotime("+1 day",strtotime("Monday this week"))}}

give the same output. The now parameter redirects his value only when a strtotime in the timestamp value is used.

locale

values: A category/locale name after RFC 1766/ISO 639

Set the locale LC_TIME information only for the plugin output.

{{date>%A: %d.%m.%y|locale=de_DE}}

So Christmas 2014 in Germany is on: Mittwoch: 24.12.2014

mode

values: date

Use the date function instead the strftime function. By default the strftime function is used.

Development

Fork me on Github and make Pull Requests. You can download preview Versions with this URL. Please note, that the preview versions maybe not fully stable.

Change Log

Known Bugs and Issues

Use the bugtracker on Github issues or email me.

ToDo/Wish List

  • robost Code

FAQ

How i get an Unix timestamp?

The Unix time gives you the number of seconds that have elapsed since 00:00:00 Coordinated Universal Time (UTC), Thursday, 1 January 1970. It's a system for describing instants in time

Use strtotime or mktime or Unix Timestamp - Epoch Converter or a Unix Epoch Time Converter

Monday this week

The strtotime('Monday this week') switches the week on sunday. This is a bug in php: strtotime seems to use both sunday and monday as start of week

Use another relative date/time format, maybe with the now parameter.

Discussion

locale key doesn't work. (Frusterick Manners)
(raspbian jessie + locale has been installed)

— dokufan Wed 22 Mar 07:27

plugin/date.txt · Last modified: 2020-09-25 06:38 by Aleksandr

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki