User Tools

Site Tools


Plugin installed incorrectly. Rename plugin directory 'swiftmail.backup' to 'swiftmail'.
en:projekt:jsfundgrube:datepicker_format
The entry about the datepicker can be found here.

Changing the date's format in the datepicker

With this javascript function you can change the date's format in your own datepicker

  • e.g. 01.01.2017
  • e.g. 01-01-2017

This is the format, which is used, when storing the values in the TIM database. This way you get a pretty format for WordTemplates, Mailnodes] etc. Therefor a new datepicker has to be implemented in the custom.js, which overrides the one in TIM. In the [[en:software:tim:smartform|Smartform we need, like with the normal datepicker, input field with a class. In this example the class datefield is used.

<form initMethod="initMyDateField">
<input type="text" name="myDateField" id="myDateField" class="datefield"/> Date
</form>

jQuery is required here and must be imported!

jq= (this.form.ownerDocument.defaultView!=null) ? this.form.ownerDocument.defaultView.jQuery : this.form.ownerDocument.parentWindow.jQuery;

In the custom file the datepicker is now being initialized in the function initMyDateField (name is freely selectable)

 gadget.functions.initMyDateField = function(){
     jq= (this.form.ownerDocument.defaultView!=null) ? this.form.ownerDocument.defaultView.jQuery : this.form.ownerDocument.parentWindow.jQuery;
     jq('.datefield').datepicker(jq.datepicker.regional["de"]);
 }

The datepicker can be given different regional formats. In this example “de” was given, which leads to: 31.07.2013

There are of course further formats available, all the way to naming the weekdays and months. Therefor you can look in the jQuery API for datepicker (http://api.jqueryui.com/datepicker/).

en/projekt/jsfundgrube/datepicker_format.txt · Last modified: 2021/07/01 09:52 (external edit)