====== date Plugin ======
---- plugin ----
description: A wrapper plugin for the php functions strftime and date
author : Marcel Pietschmann
email : mpietsch@astro.physik.uni-potsdam.de
type : syntax
lastupdate : 2016-08-28
compatible : Detritus, Hrun, Elenor of Tsort
depends :
conflicts :
similar :
tags : date, time, strftime, syntax
downloadurl: https://github.com/maphy-psd/dokuwiki-plugin-date/zipball/master
bugtracker : https://github.com/maphy-psd/dokuwiki-plugin-date/issues
sourcerepo : https://github.com/maphy-psd/dokuwiki-plugin-date/
donationurl:
screenshot_img :
----
===== Description =====
This plugin gives you the possibilities of the [[http://php.net/manual/en/function.strftime.php|strftime]] or [[http://php.net/manual/en/function.date.php|date]] function. With the [[http://php.net/manual/en/datetime.formats.relative.php|relative date/time formats]] for the [[http://php.net/manual/en/function.strtotime.php|strtotime]] function you can create any date/time output you want.
===== Installation =====
Search and install the plugin using the [[plugin:extension|Extension Manager]]. Refer to [[:Plugins]] on how to install plugins manually.
For development version, see [[plugin:date#development|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 [[http://php.net/manual/en/function.strftime.php|strftime]] and [[http://php.net/manual/en/function.date.php|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 [[https://github.com/maphy-psd/dokuwiki-plugin-date/|Github]] and make Pull Requests. You can download preview Versions with this [[https://github.com/maphy-psd/dokuwiki-plugin-date/zipball/RC|URL]]. Please note, that the preview versions maybe not fully stable.
=== Change Log ===
See [[https://github.com/maphy-psd/dokuwiki-plugin-date/releases|Github releases]]
=== Known Bugs and Issues ===
Use the bugtracker on [[https://github.com/maphy-psd/dokuwiki-plugin-date/issues|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 [[http://php.net/manual/en/function.strtotime.php|strtotime]] or [[http://php.net/manual/en/function.mktime.php|mktime]] or [[http://www.unixtimestamp.com|Unix Timestamp - Epoch Converter]] or a [[https://www.easyunitconverter.com/unix-epoch-time-converter|Unix Epoch Time Converter]]
==== Monday this week ====
The strtotime('Monday this week') switches the week on sunday. This is a bug in php:
[[https://bugs.php.net/bug.php?id=63740|strtotime seems to use both sunday and monday as start of week]]
Use another [[http://php.net/manual/en/datetime.formats.relative.php|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//