DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:date

date Plugin

Compatible with DokuWiki

  • 2017-02-19 "Frusterick Manners" unknown
  • 2016-06-26 "Elenor Of Tsort" yes
  • 2015-08-10 "Detritus" yes
  • 2014-09-29 "Hrun" yes

plugin A wrapper plugin for the php functions strftime and date.

Last updated on
2016-03-25
Provides
Syntax
Repository
Source

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

Install the plugin using the Plugin Manager and this download URL, which points to latest stable version of the plugin. For development version, see Development See plugin_installation_instructions on how to install plugins manually.

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 a Unix Timestamp - Epoch 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: 2017-03-22 05:33 by 77.12.118.203